diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-06-24 18:52:27 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-06-24 18:52:27 (GMT) |
commit | e71db4450cc3ede22dbfda7c7eb9149cf685650f (patch) | |
tree | d80ee8458e5681f6584f9f2ac7f479dbcf6ee1f9 /Lib/test/test_signal.py | |
parent | fcb17e13da46c75f76766f8536d5823563d10f1c (diff) | |
download | cpython-e71db4450cc3ede22dbfda7c7eb9149cf685650f.zip cpython-e71db4450cc3ede22dbfda7c7eb9149cf685650f.tar.gz cpython-e71db4450cc3ede22dbfda7c7eb9149cf685650f.tar.bz2 |
Issue #12392: fix thread initialization on FreeBSD 6
On FreeBSD6, pthread_kill() doesn't work on the main thread before the creation
of the first thread. Create therefore a dummy thread (no-op) a startup to
initialize the pthread library.
Add also a test for this use case, test written by Charles-François Natali.
Diffstat (limited to 'Lib/test/test_signal.py')
-rw-r--r-- | Lib/test/test_signal.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index 8a5a408..f230316 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -295,6 +295,31 @@ class WakeupSignalTests(unittest.TestCase): self.check_signum(signum1, signum2) + @unittest.skipUnless(hasattr(signal, 'pthread_kill'), + 'need signal.pthread_kill()') + def test_pthread_kill_main_thread(self): + # Test that a signal can be sent to the main thread with pthread_kill() + # before any other thread has been created (see issue #12392). + code = """if True: + import threading + import signal + import sys + + def handler(signum, frame): + sys.exit(3) + + signal.signal(signal.SIGUSR1, handler) + signal.pthread_kill(threading.get_ident(), signal.SIGUSR1) + sys.exit(1) + """ + + with spawn_python('-c', code) as process: + stdout, stderr = process.communicate() + exitcode = process.wait() + if exitcode != 3: + raise Exception("Child error (exit code %s): %s" % + (exitcode, stdout)) + def setUp(self): import fcntl |