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 neologix, rpointel, vstinner
Date 2011-09-06.21:46:15
SpamBayes Score 2.101418e-06
Marked as misclassified No
Message-id <1315345576.61.0.523842116768.issue12905@psf.upfronthosting.co.za>
In-reply-to
Content
> > read() is interrupted after 1 second, it works.
> Does it still work if you don't a create thread beforehand?

Yes, the read() is also interrupted as expected if no thread is created.

> one difference is that Python uses sigaction to setup the signal handler

If the handler is installed using the following code, read() is interrupted:
----------
sigemptyset(&sa.sa_mask);
sa.sa_handler = handler;
sa.sa_flags = 0;
sigaction(SIGALRM, &sa, NULL);
----------

Using sa.sa_flags=SA_RESTART, read() hangs (it is not interrupted). Python uses sigaction with flags=0.

> You could try with sigaction/SA_RESTART.

Using SA_RESTART, read() is not interrupted. But if the program is linked to pthread, read() is always interrupted: with sa_flags=0 or sa_flags=SA_RESTART.

> But OpenBSD's pthread implementation has severe limitations/bugs.

rthread doc contains:

"Future work:

Quite simply, signal handling is one the most complicated aspects of threads to get right. (...)"

http://www.openbsd.org/papers/eurobsd2005/tedu-rthreads.pdf
History
Date User Action Args
2011-09-06 21:46:16vstinnersetrecipients: + vstinner, neologix, rpointel
2011-09-06 21:46:16vstinnersetmessageid: <1315345576.61.0.523842116768.issue12905@psf.upfronthosting.co.za>
2011-09-06 21:46:16vstinnerlinkissue12905 messages
2011-09-06 21:46:15vstinnercreate