This commit is contained in:
root
2026-02-10 02:54:13 +08:00
parent 4a59323398
commit 64bfd85368
22 changed files with 2572 additions and 422 deletions

View File

@@ -115,7 +115,7 @@ class OccupationResolver:
try:
result = subprocess.run(
["sudo", "lsof", device_path],
capture_output=True, text=True, timeout=10
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8', timeout=10
)
if result.returncode == 0 and result.stdout.strip():
logger.info(f"设备 {device_path} 被以下进程占用:\n{result.stdout}")
@@ -127,7 +127,7 @@ class OccupationResolver:
try:
result = subprocess.run(
["sudo", "fuser", device_path],
capture_output=True, text=True, timeout=10
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8', timeout=10
)
if result.returncode == 0 and result.stdout.strip():
logger.info(f"设备 {device_path} 被以下进程占用: {result.stdout.strip()}")
@@ -149,7 +149,7 @@ class OccupationResolver:
# 使用 fuser -k 终止进程
result = subprocess.run(
["sudo", "fuser", "-k", device_path],
capture_output=True, text=True, timeout=10
stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8', timeout=10
)
if result.returncode == 0 or result.returncode == 1: # 1 表示没有进程被终止