summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-04-04 09:05:21 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-04-04 09:05:21 (GMT)
commitda9edae1f4adb9d1289a557b5fb99075bfe690d5 (patch)
tree5bbe18af62a2cf9431337bebdea77aedb267cb90
parent58f41c27bc16b733db8508415269253dd50fa139 (diff)
downloadcpython-da9edae1f4adb9d1289a557b5fb99075bfe690d5.zip
cpython-da9edae1f4adb9d1289a557b5fb99075bfe690d5.tar.gz
cpython-da9edae1f4adb9d1289a557b5fb99075bfe690d5.tar.bz2
Issue #11753: faulthandler thread uses pthread_sigmask()
The thread must not receive any signal. If the thread receives a signal, sem_timedwait() is interrupted and returns EINTR, but in this case, PyThread_acquire_lock_timed() retries sem_timedwait() and the main thread is not aware of the signal. The problem is that some tests expect that the main thread receives the signal, not faulthandler handler, which should be invisible. On Linux, the signal looks to be received by the main thread, whereas on FreeBSD, it can be any thread.
-rw-r--r--Modules/faulthandler.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index b300ef1..abc12a0 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -399,6 +399,17 @@ faulthandler_thread(void *unused)
const char* errmsg;
PyThreadState *current;
int ok;
+#ifdef HAVE_PTHREAD_H
+ sigset_t set;
+
+ /* we don't want to receive any signal */
+ sigfillset(&set);
+#if defined(HAVE_PTHREAD_SIGMASK) && !defined(HAVE_BROKEN_PTHREAD_SIGMASK)
+ pthread_sigmask(SIG_SETMASK, &set, NULL);
+#else
+ sigprocmask(SIG_SETMASK, &set, NULL);
+#endif
+#endif
do {
st = PyThread_acquire_lock_timed(thread.cancel_event,