[sudo-users] How sudo handles signals
Nuno Gonçalves
nunojpg at gmail.com
Fri Dec 16 08:59:41 EST 2011
Hi,
I'm running a very simple C program. The program have a signal handler
that print a message each time it receives a SIGINT.
nuno at nuno-boxRTx64:~/Desktop$ ./str_tp21
^CSIGINT received
^CSIGINT received
^CSIGINT received
^CSIGINT received
^CSIGINT received
^CSIGINT received
(for reading I press ENTER after each CTRL+C)
When using sudo the behavior is different:
nuno at nuno-boxRTx64:~/Desktop$ sudo ./str_tp21
^CSIGINT received
SIGINT received
^CSIGINT received
^CSIGINT received
^CSIGINT received
SIGINT received
^CSIGINT received
SIGINT received
^CSIGINT received
SIGINT received
^CSIGINT received
^CSIGINT received
SIGINT received
Most of the times - but not always, the program receives 2 signals for
each time I press CTRL+C.
On another terminal I can see 2 processes running.
root 3781 0.0 0.0 25648 1312 pts/0 S+ 13:51 0:00 sudo ./str_tp21
root 3782 68.8 0.0 10816 404 pts/0 R+ 13:51 0:09 ./str_tp21
If I send a kill -s 2 3781 or kill -s 2 3782, both will print a SINGLE
message of my program.
That means SUDO is routing the signals it receives to the child
process (my program!).
Is this supposed to happen?
nuno at nuno-boxRTx64:~$ uname -a
Linux nuno-boxRTx64 3.0.0-13-lowlatency #21ppa1~natty1-Ubuntu SMP
PREEMPT Tue Oct 18 07:08:03 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
nuno at nuno-boxRTx64:~$ sudo -V
Sudo version 1.7.4p4
Regards,
--
+ Nuno Gonçalves
+ nunojpg at gmail.com
+ http://nunoassimassim.blogspot.com/
+ PORTUGAL
E-mail sent directly from Google Mail webmail using HTTPS on behalf of
Nuno João Pinto Gonçalves, birth date 1986-11-16. This e-mail header
MUST contain a DKIM signature. If you require additional security, I
may provide on request X509 electronic signature under Portuguese
government chain.
Se precisar de assinatura digital do Cartão de Cidadão, de uma apitadela.
More information about the sudo-users
mailing list