kill code-server with sudo kill
This commit is contained in:
@@ -205,9 +205,11 @@ class ChatManager:
|
||||
return True # 已退出
|
||||
|
||||
try:
|
||||
# 优雅:向进程组发 SIGTERM
|
||||
os.killpg(pop.pid, signal.SIGTERM)
|
||||
print("send SIGTERM to code-server")
|
||||
subprocess.run(
|
||||
["sudo", "kill", "-TERM", str(pop.pid)],
|
||||
check=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
except ProcessLookupError:
|
||||
return True
|
||||
|
||||
@@ -222,7 +224,11 @@ class ChatManager:
|
||||
# 兜底:强杀进程组
|
||||
try:
|
||||
print("kill code-server")
|
||||
os.killpg(pop.pid, signal.SIGKILL)
|
||||
subprocess.run(
|
||||
["sudo", "kill", "-KILL", str(pop.pid)],
|
||||
check=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
except ProcessLookupError:
|
||||
pass
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user