You are falling because you are trying to recursively process the signal.
When using signal()a signal handler for registration, this signal number is blocked until the signal handler returns - in fact, the / libc kernel blocks this signal number when the signal handler is called and unlocks it after the signal handler returns, since you never return from the signal handler (instead, you are a execlnew binary), SIGUSR1remains blocked and therefore does not fall a second time.
This can be seen by examining /proc/</pid>/statusbefore and after sending the first SIGUSR1.
Before:
$ cat /proc/<pid>/status | grep -E "Sig(Cgt|Blk)"
SigBlk: 0000000000000000
SigCgt: 0000000000000200
After:
$ cat /proc/<pid>/status | grep -E "Sig(Cgt|Blk)"
SigBlk: 0000000000000200
SigCgt: 0000000000000200
, SigCgt , 10 ( - , 10 , SIGUSR1, . man signal(7) ). SigBlk SIGUSR , SIGUSR1.
:
). SIGUSR execl sighandler:
sigset_t sigs;
sigprocmask(0, 0, &sigs);
sigdelset(&sigs, SIGUSR1);
sigprocmask(SIG_SETMASK, &sigs);
). sigaction SA_NODEFER signal . SIGUSR1 :
struct sigaction act;
act.sa_handler = signalhandler;
act.sa_mask = 0;
act.sa_flags = SA_NODEFER;
sigaction(SIGUSR1, &act, 0);