PreviousNext

Signal Rules

The following rules summarize correct signal handing practices for multithreaded programs.

· Signals must be blocked prior to being waited for. The sigwait( ) routine waits for blocked (masked) signals.

· In order to avoid unpredictable behavior, all asynchronous signal handling should be confined to one signal catcher thread. This may be extended to a set of signal catcher threads.

· The pthread_cond_signal( ) routine cannot safely be used in a signal handler that is invoked asynchronously. In general, mutexes and condition variables are not suitable for releasing a waiting thread in response to a signal handler. When a thread must wait for an asynchronous signal, use sigwait( ) instead.

· Signal handlers should not call the pthread routines. In general, runtime libraries cannot reliably be used in signal handlers.