[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
sigwait() and SIGSEGV
Is it possible to catch SIGSEGV in a multithreaded program?
I have a test program, the main thread creates 3 threads - 1 signal catching
thread and 2 normal threads.
The main thread masks all signals and creates the threads. The new threads
inherit the signal mask from the main thread.
pthread_t stid; /* signal thread id */
pthread_sigmask(SIG_SETMASK, &sigset, NULL);
pthread_create(&stid, NULL, &sig_thread, &sigset);
/* Create other threads */
Below is the signal catching thread, which calls sigwait() in a loop and for
each signal it prints the name:
/* Signal handling thread */
void *sig_thread(void *arg)
sigset_t *sigset = (sigset_t *)arg;
printf("Got signal %d, exiting\n", signum);
If one of the other threads dereferences a NULL pointer, the program hangs. I
don't understand why sigwait() does not catch SIGSEGV. Does sigwait() only
work with asynchronous signals?
Main Index |
Thread Index |