Skip to content

Commit b8e9cf1

Browse files
authored
Merge pull request slgobinath#680 from sudoAlphaX/user-specific-run-check
feat: check if the running process is of the same user
2 parents 861fee3 + db0137c commit b8e9cf1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

safeeyes/__main__.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
def __running():
4141
"""Check if SafeEyes is already running."""
4242
process_count = 0
43+
current_user = psutil.Process().username()
4344
for proc in psutil.process_iter():
4445
if not proc.cmdline:
4546
continue
@@ -54,9 +55,10 @@ def __running():
5455
if ("python3" in cmd_line[0] or "python" in cmd_line[0]) and (
5556
"safeeyes" in cmd_line[1] or "safeeyes" in cmd_line
5657
):
57-
process_count += 1
58-
if process_count > 1:
59-
return True
58+
if proc.username() == current_user:
59+
process_count += 1
60+
if process_count > 1:
61+
return True
6062

6163
# Ignore if process does not exist or does not have command line args
6264
except (IndexError, psutil.NoSuchProcess):

0 commit comments

Comments
 (0)