I want to handle the signal SIGTSTP (18) on Linux. This is my code:
void handler(int signum){
printf("Signal %d has tried to stop me.", signum);
}
int main(void){
struct sigaction act;
sigset_t mask;
act.sa_handler = handler;
act.sa_flags = 0;
sigemptyset(&mask);
sigaddset(&mask, SIGTSTP);
sigprocmask(SIG_SETMASK, &mask, NULL);
sigaction(SIGTSTP, &act, NULL);
pause();
}
When I send a signal from another terminal this way:
$ kill -18 PID
the handler() function does not run. I've tried replacing SIGTSTP with 18 in the call to sigaction(). It does not work.
Any ideas? Thanks for your time.