README
1Test the interaction of signals with multiple posix threads.
2
3Signal SIGUSR1 is used for thread coordination, SIGUSR2 to test
4signal delivery. First SIGUSR1 and SIGUSR2 get blocked. Then a
5given number of threads are created, the main thread is also counted
6as a thread.
7
8Signal SIGUSR2 is send to the process with kill(2), but it is not
9delivered yet as it is blocked in all threads. Meanwhile the threads
10wait for SIGUSR1 in sigsuspend(2). This enforces that SIGUSR2 is
11marked as pending at the process. To continue, SIGUSR1 is sent to
12all threads and they wake up. Only one thread is configured to
13handle SIGUSR2, this one unblocks it with pthread_sigmask(3). The
14signal should be delivered immediately, the handler records it.
15
16The test is considered successful if the thread that unblocks SIGUSR2
17actually handles it.
18
19To test different race conditions, sleeps can be inserted. If the
20kill(2) is delayed, SIGUSR2 hits the threads when they are in
21sigsuspend(2). If the sleep is before sigsuspend(2), the threads
22are in nanosleep(2). The unblocking pthread_sigmask(3) can be
23delayed so that the other threads have been joined already.
24
25It is also possible to avoid blocking the signals and check which
26handler catches it. Alternatively sigwait(3) can be used to test
27signal reception.
28