Skip to content

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

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

Merged
merged 1 commit into from
Mar 25, 2025
Merged

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

merged 1 commit into from
Mar 25, 2025

Conversation

sudoAlphaX
Copy link
Contributor

@sudoAlphaX sudoAlphaX commented Feb 21, 2025

When running SafeEyes in multi-user environments (multiple users running
SafeEyes in the same machine), it refuses to start more than one
instance of SafeEyes because it is already running accoding to ps.

This patch adds a check to the running SafeEyes pid such that the
_running() function returns True only if it is running as the same user.

Please check if the Windows platform works as expected.

@deltragon
Copy link
Collaborator

GTK (specifically, GtkApplication) actually has handling for that, and in theory should be able to handle all this by itself. I'd much prefer to move both the "is another instance running" detection as well as the CLI command handling to GTK's builtin support, which would then fix this issue as well.
Especially for eg. sandboxed packaging (like Flatpaks), this will be necessary as well.
So I'd much rather try and shoot for the proper fix of using GTK here rather than adding more to our home-grown solution.
I am open to merging this as a stop-gap, however, if you think this is urgent enough.

@deltragon
Copy link
Collaborator

(Regarding Windows support: SafeEyes strongly depends on either X11 or Wayland - I don't think it runs on Windows, and it certainly isn't actively supported.)

@sudoAlphaX
Copy link
Contributor Author

I am open to merging this as a stop-gap, however, if you think this is urgent enough.

I would appreciate if you merge this as a temporary measure, since currently, it is impossible to use two instances of SafeEyes with different user accounts.

In the mean time, ill start looking on the native GtkApplication handling (but no promises though)

When running SafeEyes in multi-user environments (multiple users running
SafeEyes in the same machine), it refuses to start more than two
instances of SafeEyes because it is already running accoding to ps.

This patch adds a check to the running SafeEyes pid such that the
_running() function returns True only if it is running as the same user.
Copy link
Collaborator

@deltragon deltragon left a comment

Choose a reason for hiding this comment

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

LGTM.
As I said, I'd prefer if this is replaced long-term with GtkApplication handling, but this is fine as a short-term fix.

@deltragon
Copy link
Collaborator

Thanks!

@deltragon deltragon merged commit b8e9cf1 into slgobinath:master Mar 25, 2025
2 checks passed
@sudoAlphaX sudoAlphaX deleted the user-specific-run-check branch March 27, 2025 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants