New submission from Armin Ronacher <armin.ronac...@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.

Testcase:

mitsuh...@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)
0
>>> import sys
>>> sys.stdin.read()
^Z
[1]+  Stopped                 python2.7
mitsuh...@nausicaa:~$ fg
python2.7
Got SIGCONT
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.

----------
messages: 116504
nosy: aronacher
priority: normal
severity: normal
status: open
title: Interrupted system calls are not retried on OS X
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3

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

Reply via email to