Reputation: 93
I have a problem with this code..
I need to put in wait (sigwait
) a process until arrive two Signals SIGUSR1
/SIGUSR2
(maybe I can use sigalrm
to catch the signals?)
#include <signal.h>
#include <stdio.h>
int main()
{
sigset_t set;
int sig;
sigemptyset(&set);
sigaddset(&set, SIGUSR1);
sigaddset(&set, SIGUSR2);
sigprocmask(SIG_BLOCK, &set, NULL);
sigwait(&set, &sig);
printf("Got signal %d\n", sig);
/*need to set Sigalrm?*/
return 0;
}
Upvotes: 1
Views: 479
Reputation: 798526
Pass select()
the read end of a pipe. When you catch the signal, write to the pipe. This will cause select()
to return and execution to continue.
Upvotes: 1