STINNER Victor <victor.stin...@haypocalc.com> added the comment:

> > 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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12905>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to