STINNER Victor <victor.stin...@haypocalc.com> added the comment: > “If a signal is delivered to a thread waiting for a condition variable, > upon return from the signal handler the thread resumes waiting for the > condition > variable as if it was not interrupted, or it shall return zero due to spurious > wakeup.”
Confirmed on Linux (kernel 2.6.37, eglibc 2.11.2) using strace: -------- 10:42:59.942455 futex(0x173fabc, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, {1303202584, 942432000}, ffffffff) = ? ERESTART_RESTARTBLOCK (To be restarted) 10:43:00.941777 --- SIGALRM (Alarm clock) @ 0 (0) --- 10:43:00.941848 rt_sigreturn(0x1462eac) = -1 EINTR (Interrupted system call) 10:43:00.941926 futex(0x173fabc, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, {1303202584, 942432000}, ffffffff) = -1 ETIMEDOUT (Connection timed out) 10:43:04.942650 futex(0x173fae8, FUTEX_WAKE_PRIVATE, 1) = 0 -------- pthread_cond_timedwait() is interrupted: the system call returns ERESTART_RESTARTBLOCK (To be restarted), and then the system call is restarted. I think that we should just skip the test if Python uses pthread without semaphore and pthread_cond_timedwait() restarts if it is interrupted by a signal. Attached C program checks if pthread_cond_timedwait() does restart or not. On Linux, it should be compiled using: gcc -pthread -lrt pthread_cond_timedwait_signal.c -o pthread_cond_timedwait_signal I don't know how to integrate pthread_cond_timedwait_signal.c into configure.in. I don't know if any OS does NOT restart pthread_cond_timedwait() after an interruption, so it's maybe simpler to always skip test_lock_acquire_interruption() and test_rlock_acquire_interruption() of test_threadsignals if Python uses pthread without semaphore. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11223> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com