exitcode = os.waitpid(pid, 0)
assert exitcode == 0 # if 9, process was killed by timer!
+ def test_forked_is_main_thread(self):
+ "Checks that a forked interpreter is the main thread"
+ import os, thread, signal
+ if not hasattr(os, 'fork'):
+ skip("No fork on this platform")
+ # signal() only works from the 'main' thread
+ signal.signal(signal.SIGUSR1, signal.SIG_IGN)
+ self.timeout_killer(pid, 5)
+ exitcode = os.waitpid(pid, 0)
+ thread.start_new_thread(threadfunction, ())
+ self.waitfor(lambda: feedback)
+ # if 0, an (unraisable) exception was raised from the forked thread.
+ # if 9, process was killed by timer.
+ # if 42<<8, os._exit(42) was correctly reached.
+ assert feedback == [42<<8]