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 imap.gmail.com --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 imap.gmail.com --starttls \_ gnutls-cli -p smtp imap.gmail.com --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?