Subj : NPTL and sigwait() problem under linux To : comp.programming.threads From : Daniele Date : Tue Aug 16 2005 07:18 pm I want to create a thread that handles all the signals sent to the process, and all the other threads shouldn't be aware of signals at all. I used sigprocmask() to block all the signals before creating any thread, then I spawn a thread that calls sigwait(), and it used to work (with LinuxThreads). Now I have a debian sid system, with kernel 2.6.11.7 and NPTL, and it doesn't work anymore. I tried to use pthread_sigmask instead of sigprocmask(), but nope. Thanks for any help, Daniele This is the code: static int terminate = 0; void* signal_thread(void* param) { sigset_t *set = (sigset_t*) param; int sig; while(!terminate) { sigwait(set, &sig); switch(sig) { case SIGINT: case SIGTERM: /* ...do cleanup, etc... */ terminate = 1; break; case SIGUSR1: /* ...handle the signal here... */ break; } return NULL; } static pthread_t sig_thr = (pthread_t) 0; void signal_init(void) { static sigset_t signals; int err; sigemptyset(&signals); sigaddset(&signals, SIGTERM); sigaddset(&signals, SIGINT); sigaddset(&signals, SIGUSR1); sigprocmask(SIG_BLOCK, &signals, NULL); err = pthread_create(&sig_thr, NULL, signal_thread, &signals); if(err != 0) { fprintf(stderr, "signal_init (pthread_create): %s\n", strerror(err)); exit(err); } } void signal_finish(void) { if(sig_thr != (pthread_t) 0) { pthread_cancel(sig_thr); pthread_join(sig_thr, NULL); } } int main(void) { signal_init(); /* ... run program, create other threads, etc... */ signal_finish(); return 0; } .