[sudo-users] How sudo handles signals

Nuno Gonçalves nunojpg at gmail.com
Fri Dec 16 20:17:10 EST 2011


test.c

#include <stdio.h>
#include <signal.h>

void sigint_handler(int sig)
{
	printf("SIGINT received\n");
}

int main(int argc, char* argv[])
{
	signal(SIGINT,sigint_handler);
	while(1);
	return 0;
}

nuno at nuno-boxRTx64:~/Desktop$ gcc test.c -o test
nuno at nuno-boxRTx64:~/Desktop$ sudo ./test
^CSIGINT received
^CSIGINT received
SIGINT received
^CSIGINT received
^CSIGINT received
SIGINT received
^CSIGINT received
SIGINT received
^CSIGINT received


We can see more than one SIGINT for each ^C (but not always).

Regards,
Nuno

2011/12/16 Todd C. Miller <Todd.Miller at courtesan.com>:
> I don't see that behavior myself, but from the code it seems possible
> if you do not have log_output enabled.
>
> The main sudo process forwards signals to the command it is running
> which is fine in general.  However, in the case of keyboard-generated
> signals it may be possible for both processes to receive SIGINT and
> thus for the command to get the signal twice.  As I said, I don't
> see that with a simple test program.  Can you share the code you
> are using?
>
>  - todd




More information about the sudo-users mailing list