mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-28 15:08:49 +03:00
Avoid waiting for zombie processes in synctl stop
(#11490)
This commit is contained in:
parent
858d80bf0f
commit
b50e39df57
2 changed files with 17 additions and 3 deletions
1
changelog.d/11490.feature
Normal file
1
changelog.d/11490.feature
Normal file
|
@ -0,0 +1 @@
|
|||
`synctl stop` will now wait for Synapse to exit before returning.
|
17
synctl
17
synctl
|
@ -41,12 +41,25 @@ NORMAL = "\x1b[m"
|
|||
def pid_running(pid):
|
||||
try:
|
||||
os.kill(pid, 0)
|
||||
return True
|
||||
except OSError as err:
|
||||
if err.errno == errno.EPERM:
|
||||
return True
|
||||
pass # process exists
|
||||
else:
|
||||
return False
|
||||
|
||||
# When running in a container, orphan processes may not get reaped and their
|
||||
# PIDs may remain valid. Try to work around the issue.
|
||||
try:
|
||||
with open(f"/proc/{pid}/status") as status_file:
|
||||
if "zombie" in status_file.read():
|
||||
return False
|
||||
except Exception:
|
||||
# This isn't Linux or `/proc/` is unavailable.
|
||||
# Assume that the process is still running.
|
||||
pass
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def write(message, colour=NORMAL, stream=sys.stdout):
|
||||
# Lets check if we're writing to a TTY before colouring
|
||||
|
|
Loading…
Reference in a new issue