Paste #40
Welcome On LodgeIt
Welcome to the LodgeIt pastebin. In order to use the notification feature a 31 day cookie with an unique ID was created for you. The lodgeit database does not store any information about you, it's just used for an advanced pastebin experience :-). Read more on the about lodgeit page. Have fun :-)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | For sigwait to work reliably, the signals being waited for must be
blocked in all threads, not only in the calling thread, since otherwise
the POSIX semantics for signal delivery do not guarantee that it's the
thread doing the sigwait that will receive the signal. The best way to
achieve this is block those signals before any threads are created, and
never unblock them in the program other than by calling sigwait.
Signal handling in LinuxThreads departs significantly from the POSIX
standard. According to the standard, ``asynchronous'' (external) sig‐
nals are addressed to the whole process (the collection of all
threads), which then delivers them to one particular thread. The thread
that actually receives the signal is any thread that does not currently
block the signal.
In LinuxThreads, each thread is actually a kernel process with its own
PID, so external signals are always directed to one particular thread.
If, for instance, another thread is blocked in sigwait on that signal,
it will not be restarted.
The LinuxThreads implementation of sigwait installs dummy signal han‐
dlers for the signals in set for the duration of the wait. Since signal
handlers are shared between all threads, other threads must not attach
their own signal handlers to these signals, or alternatively they
should all block these signals (which is recommended anyway -- see the
Notes section).
|