This patch adds the capability to cloned processes to have a shared signal queue. This enables the LinuxThreads implementation of POSIX threads to have POSIX compliant signal delivery behaviour.
In order to POSIX compliant, signals sent to a threaded program can be received by any thread. Currently, a signal sent to one of the threads of such a program is received only by that thread.
The kernel patch introduces a new clone flag: CLONE_SHRD_SIGQ. The flag creates a special shared signal queue which is shared between the process performing the clone and the newly cloned process. Signals sent to either one of these processes end up in the shared signal queue. If you want to send in this case a signal to a specific process, you have to call the new system call kill_thread.
Each process has now a shared and a private queue. The private queue is equal to the existing process specific signal queue (and sigset_t). The private queue receives thread specific signals such as SIGSEGV, SIGBUS, etc. and signals sent by kill_thread. The shared queue receives signals sent via kill() or sigqueue() or signals coming from POSIX timers, or signals from asynchronous I/O notifications. The last feature combined with the fcntl(fd, F_SETSIG, rt-signal) feature, would give you a way to make a multi-threaded server application receiving a signal for every ready socket, which could be serviced by any of the threads waiting on such a signal.
Signal masks are always thread specific. It is possible to have also a shared signal mask, but it has not been implemented (yet?). The functions pthread_sigmask() and sigprocmask() do the same. They both set the private signal mask.
When a signal is sent to a group of processes, more than one process
in that group can wake up. One of the processes will consume the
pending signal, leaving nothing for the other. Both processes however
have their signal pending flag set. The last process will check in
vain for the pending signal and will complain with the following
SIG: sigpending lied
Patch for Linux 2.3.31 gz or bz2
Patch for Linux 2.3.99-pre3 gz or bz2
The patch adds the system call kill_thread() and patches linux threads to use it for pthread_kill() and for its own internal use.
Last update: March 29, 2000