Skip to content

Commit 61b893b

Browse files
authored
👌 IMPROVE: Check for recycled circus PID (#4858)
Ensure the PID is from the original user.
1 parent f99f1e8 commit 61b893b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

‎aiida/cmdline/utils/daemon.py

+5
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,13 @@ class StartCircusNotFound(Exception):
126126
if pid is not None:
127127
try:
128128
process = psutil.Process(pid)
129+
# the PID got recycled, but a different process
129130
if _START_CIRCUS_COMMAND not in process.cmdline():
130131
raise StartCircusNotFound() # Also this is a case in which the process is not there anymore
132+
133+
# the PID got recycled, but for a daemon of someone else
134+
if process.username() != psutil.Process().username(): # compare against the username of this interpreter
135+
raise StartCircusNotFound()
131136
except (psutil.AccessDenied, psutil.NoSuchProcess, StartCircusNotFound):
132137
echo.echo_warning(
133138
f'Deleted apparently stale daemon PID file as its associated process<{pid}> does not exist anymore'

0 commit comments

Comments
 (0)