[issue21895] signal.pause() doesn't wake up on SIGCHLD in non-main thread
STINNER Victor
report at bugs.python.org
Tue Jul 1 12:31:10 CEST 2014
STINNER Victor added the comment:
First of all, signals and threads usually don't play together. Most signal functions are *not* thread safe. The behaviour of signal functions are not well defined for threads.
Example with pause:
"pause() causes the calling process (or thread) to sleep until a signal is delivered that either terminates the process or causes the invocation of a signal-catching function."
What does it mean "or thread"? Sometimes the function waits for a signal from any thread, something only from the caller thread? :-p
I understood that pause() only waits for signals received in the caller thread, main thread in your case.
Depending on the platform, a signal may be delivered to a different thread :-/ Especially when a signal is send to the process, ex: "kill -USR1 pid" command on UNIX.
This issue is more a documentation issue: we should mention that pause() is limited to a thread.
Python signal handlers are only called from the main thread, even if signals can be received from any thread.
For your example, you can workaround pause() issue by calling "signal.pthread_sigmask(signal.SIG_BLOCK, [signal.SIGCHLD])" in your thread.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21895>
_______________________________________
More information about the Python-bugs-list
mailing list