Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I would like to execute an application (gnutls-cli) as another user and send a signal to it (SIGALRM). Unfortunately this does not work:

sudo -u myuser gnutls-cli -p smtp --starttls &
sudo -u myuser kill -ALRM $!

gnutls-cli is a child of the sudo process, that is I got the following process tree:

\_ sudo -u myuser gnutls-cli -p smtp --starttls
    \_ gnutls-cli -p smtp --starttls

this means the signal is sent to the outer sudo process. Obviously this does not work at all.

Is there any way to get sudo to exec the subprocess directly or to forward signals to its child?


share|improve this question

1 Answer 1

A quick look at the man pages for sudo and sudoers reveal nothing obvious to solve this problem, but can I offer an alternative solution?

Wrap the original program in a script that will save the spawned pid# into a pidfile, which you can reference later. For example:


gnutls-cli $@ &
echo $! > /home/myuser/var/

Then, from sudo you can run:

sudo -u myuser /home/myuser/scripts/ -p smtp --starttls &

Then, later:

sudo -u myuser kill -ALRM $(cat /home/myuser/var/

I hope you find this helpful.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.