/* to enable the signal 33 you have to unblock signal 32 instead of 33!*/ #include #include #include #include #define SIGNAL1 33 /* SIGRTMIN */ int sig_received; void sigminrt_handler(int signo, siginfo_t * info, void * ptr) { sig_received = 1; /* we passed the handler */ } int do_test(int sig) { sig_received = 0; #ifdef PAUSE pause(); /* wait a lot */ #else sleep(10); /* wait a little bit */ #endif if (sig_received) printf("The signal %d was received.\n", sig); else printf("The signal %d was NOT received.\n", sig); return (sig_received); } int main() { struct sigaction sigact; sigset_t new_mask; sigact.sa_sigaction =sigminrt_handler; sigact.sa_flags = SA_SIGINFO; sigemptyset(&sigact.sa_mask); sigaction(SIGNAL1, &sigact, NULL); sigfillset(&new_mask); sigdelset(&new_mask, 32); sigprocmask(SIG_SETMASK, &new_mask, NULL); printf("Testing SIGNAL1=%d with signal %d unblocked.\n", SIGNAL1, 32); do_test(SIGNAL1); sigfillset(&new_mask); sigdelset(&new_mask, SIGNAL1); sigprocmask(SIG_SETMASK, &new_mask, NULL); printf("Testing SIGNAL1=%d with signal %d unblocked.\n", SIGNAL1, SIGNAL1); do_test(SIGNAL1); return 0; }