rejeep / prodigy.el

Manage external services from within Emacs
GNU General Public License v3.0
550 stars 39 forks source link

Properly stop process started with sudo #144

Open isamert opened 2 months ago

isamert commented 2 months ago

Prodigy can't stop processes started with sudo because it does not have the privileges to do that. This PR simply fixes that by running the kill command with prodigy-start-sudo-process and with given stop-signal. Partially fixes #111.

Fuco1 commented 1 month ago

Maybe a different approach would be to set default directory using TRAMP and sudo protocol and then call the original code. I would as much as possible try to use the stop-process and similar Emacs commands instead of using utilities such as pgrep which aren't necessarily very portable.

isamert commented 1 month ago

While writing a response I figured out a way to not depending on pgrep, turns out sending the signal with appending - before the process group id redirects the signal to all children, which greatly simplified the implementation.

I agree that utilizing TRAMP would be the best possible solution but there are a few blockers:

Currently killing services with :sudo t does not work at all, this PR at least fixes that. With the latest change, it's even simpler.

Fuco1 commented 1 month ago

Sounds good to me. Plus if it fixes the issue for at least some portion of the users that's a good change for me. It seems to be backward compatible with the non-sude tasks.

We can think about the refactor later, but I think there is already enough value to merge this. Thanks for looking into it!

Fuco1 commented 1 month ago

Apparently this repo requires all commits to be signed:

image

Is this an option for you? If not, I can rebase them somehow so they get signed (it should still retain you as the author though, I don't want to take the credit)

This is the link: https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification

isamert commented 1 month ago

Sorry for getting back late, thanks for the heads up. Signed the commits and updated.