Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit b50e39d

Browse files
authored
Avoid waiting for zombie processes in synctl stop (#11490)
1 parent 858d80b commit b50e39d

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

changelog.d/11490.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
`synctl stop` will now wait for Synapse to exit before returning.

synctl

+16-3
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,24 @@ NORMAL = "\x1b[m"
4141
def pid_running(pid):
4242
try:
4343
os.kill(pid, 0)
44-
return True
4544
except OSError as err:
4645
if err.errno == errno.EPERM:
47-
return True
48-
return False
46+
pass # process exists
47+
else:
48+
return False
49+
50+
# When running in a container, orphan processes may not get reaped and their
51+
# PIDs may remain valid. Try to work around the issue.
52+
try:
53+
with open(f"/proc/{pid}/status") as status_file:
54+
if "zombie" in status_file.read():
55+
return False
56+
except Exception:
57+
# This isn't Linux or `/proc/` is unavailable.
58+
# Assume that the process is still running.
59+
pass
60+
61+
return True
4962

5063

5164
def write(message, colour=NORMAL, stream=sys.stdout):

0 commit comments

Comments
 (0)