#include #include #include static void *thread_loop (void *unused) { sigset_t block_set, pending_set; sigemptyset (&block_set); sigaddset (&block_set, SIGUSR2); if (pthread_sigmask (SIG_BLOCK, &block_set, NULL) != 0) { printf ("failed to set the list of blocked signals\n"); } while (1) { sigpending (&pending_set); printf ("pending_set = %08X\n", pending_set); if (sigismember (&pending_set, SIGUSR2) != 0) break; sleep (1); } printf ("exiting thread_loop()\n"); return NULL; } int main (int argc, char **argv) { int rv; pthread_t thr_id; rv = pthread_create (&thr_id, NULL, thread_loop, NULL); if (rv != 0) { printf ("failed to create thread.\n"); exit (1); } /* give the second thread a chance to run */ sleep (5); while (1) { if (pthread_kill (thr_id, SIGUSR2) != 0) break; } exit (0); }