c - Stuck with sigwait -
i did wrong in code, other process send sigusr2 signal it:
sigset_t sigset; sigemptyset(&sigset); sigaddset(&sigset, sigill); sigaddset(&sigset, sigusr2); sigwait(&sigset, &received);
xcode notices siguser2(31) signal received, received = sigill(4) (or minimal signal in set).
why so? wrong?
now, looks this:
sigset_t sigset; sigemptyset(&sigset); sigaddset(&sigset, sigill); sigaddset(&sigset, sigusr2); sigprocmask(sig_block, &sigset, 0); sigwait(&sigset, &received); if(received == sigusr2) { //... } else if(received == sigill) { //... }
still not working.
sometimes debugger can in way. have seen debuggers interfere signal handling before. try running code without debugger involved.
the following code works on os x:
#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); return 0; }
Comments
Post a Comment