--- cpython-302424b84b07/Lib/test/test_signal.py 2011-06-01 04:39:38.000000000 +0200 +++ cpython/Lib/test/test_signal.py 2011-06-10 10:47:33.521906867 +0200 @@ -601,11 +601,24 @@ @unittest.skipUnless(hasattr(signal, 'sigwait'), 'need signal.sigwait()') def test_sigwait(self): - old_handler = signal.signal(signal.SIGALRM, self.handler) - self.addCleanup(signal.signal, signal.SIGALRM, old_handler) - - signal.alarm(1) - self.assertEqual(signal.sigwait([signal.SIGALRM]), signal.SIGALRM) + # sigwait must be called with the signal blocked: since the current + # process might have several threads running, we fork() a child process + # to have a single thread. + signum = signal.SIGUSR1 + pid = os.fork() + if pid == 0: + # child: block and wait the signal + signal.pthread_sigmask(signal.SIG_BLOCK, [signum]) + res = signal.sigwait([signum]) + if res == signum: + os._exit(0) + os._exit(1) + else: + # parent: let the child some time to wait, send him the signal, and + # check it correcty received it + time.sleep(0.5) + os.kill(pid, signum) + self.assertEqual(os.waitpid(pid, 0), (pid, 0)) @unittest.skipUnless(hasattr(signal, 'pthread_sigmask'), 'need signal.pthread_sigmask()')