Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/11490.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`synctl stop` will now wait for Synapse to exit before returning.
19 changes: 16 additions & 3 deletions synctl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +50 to +59
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to better ideas. There doesn't seem to be a nice cross platform way to check the status of a process.


return True


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