Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: check if the running process is of the same user #680

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions safeeyes/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __running():
Check if SafeEyes is already running.
"""
process_count = 0
current_user = psutil.Process().username()
for proc in psutil.process_iter():
if not proc.cmdline:
continue
Expand All @@ -53,9 +54,10 @@ def __running():
# In older versions cmdline was a list object
cmd_line = proc.cmdline
if ('python3' in cmd_line[0] or 'python' in cmd_line[0]) and ('safeeyes' in cmd_line[1] or 'safeeyes' in cmd_line):
process_count += 1
if process_count > 1:
return True
if proc.username() == current_user:
process_count += 1
if process_count > 1:
return True

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