[issue12392] pthread_kill() doesn't work on the main thread on FreeBSD6
Charles-François Natali
report at bugs.python.org
Fri Jun 24 20:05:50 CEST 2011
Charles-François Natali <neologix at free.fr> added the comment:
> Attached patch implements the suggested fix.
The patch looks good to me.
> It would be possible to fix the test to fail instead of blocking
I think this issue deserves a specific test, since:
- test_pending tests something completely different
- at the time test_pending gets to run, there's a high chance that
threads have already been created
I've attached a patch spawning a new interpreter to test that.
----------
Added file: http://bugs.python.org/file22445/pthread_kill_main_thread.diff
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12392>
_______________________________________
-------------- next part --------------
diff -r 5ec95f46bac5 Lib/test/test_signal.py
--- a/Lib/test/test_signal.py Fri Jun 24 13:28:08 2011 -0400
+++ b/Lib/test/test_signal.py Fri Jun 24 20:01:37 2011 +0200
@@ -295,6 +295,31 @@
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(0)
+ """
+
+ 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
More information about the Python-bugs-list
mailing list