diff options
author | Sean Quah <8349537+squahtx@users.noreply.github.com> | 2021-12-02 16:07:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-02 16:07:06 +0000 |
commit | b50e39df578adc3f86c5efa16bee9035cfdab61b (patch) | |
tree | fc10a957a5ef6b04a70ea5fb28799bc9f31467f3 /synctl | |
parent | Fix media repository failing when media store path contains symlinks (#11446) (diff) | |
download | synapse-b50e39df578adc3f86c5efa16bee9035cfdab61b.tar.xz |
Avoid waiting for zombie processes in `synctl stop` (#11490)
Diffstat (limited to '')
-rwxr-xr-x | synctl | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/synctl b/synctl index 08709f21ab..0e54f4847b 100755 --- a/synctl +++ b/synctl @@ -41,11 +41,24 @@ 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 - return False + 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): |