This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients db3l, gregory.p.smith, neologix, pitrou, python-dev, rnk, sable, vstinner
Date 2011-04-19.09:38:58
SpamBayes Score 1.161e-08
Marked as misclassified No
Message-id <1303205940.82.0.79335775323.issue11223@psf.upfronthosting.co.za>
> “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.
Date User Action Args
2011-04-19 09:39:00vstinnersetrecipients: + vstinner, gregory.p.smith, db3l, pitrou, sable, rnk, neologix, python-dev
2011-04-19 09:39:00vstinnersetmessageid: <1303205940.82.0.79335775323.issue11223@psf.upfronthosting.co.za>
2011-04-19 09:38:58vstinnerlinkissue11223 messages
2011-04-19 09:38:58vstinnercreate