[issue9867] Interrupted system calls are not retried on OS X
report at bugs.python.org
Thu Sep 16 04:02:58 CEST 2010
New submission from Armin Ronacher <armin.ronacher at active-4.com>:
Currently Python does not check fread and other IO calls for EINTR. This usually is not an issue, but on OS X a continued program will be sent an SIGCONT signal which causes fread to be interrupted.
mitsuhiko at nausicaa:~$ python2.7
Python 2.7 (r27:82508, Jul 3 2010, 21:12:11)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from signal import SIGCONT, signal
>>> def show_signal(*args):
... print 'Got SIGCONT'
>>> signal(SIGCONT, show_signal)
>>> import sys
+ Stopped python2.7
mitsuhiko at nausicaa:~$ fg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 4] Interrupted system call
Expected behavior: on fg it should continue to read. The solution would be to loop all calls to fread and friends until errno is no longer EINTR. Now the question is how to best do that. I can't think of a portable way to define a macro that continues to run an expression until errno is EINTR, maybe someone else has an idea.
Otherwise it would be possible to just put the loops by hand around each fread/fgetc etc. call, but that would make the code quite a bit more ugly.
Technically I suppose the problem applies to all platforms, on OS X it's just easier to trigger.
title: Interrupted system calls are not retried on OS X
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list