[Python-Dev] RFC: PEP 475, Retry system calls failing with EINTR

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Sep 1 09:15:33 CEST 2014


Victor Stinner wrote:
> 
> Le 1 sept. 2014 00:17, "Marko Rauhamaa" <marko at pacujo.net 
> <mailto:marko at pacujo.net>> a écrit :
>  > If a signal is received when read() or write() has completed its task
>  > partially (> 0 bytes), no EINTR is returned but the partial count.
>  > Obviously, Python should take that possibility into account so that
>  > raising an exception in the signal handler (as mandated by the PEP)
>  > doesn't cause the partial result to be lost on os.read() or os.write().
> 
> This case is unrelated to the PEP, the PEP only changes the behaviour 
> when a syscall fails with EINTR.

I think there's a problem here, though. As thing stand, a
signal handler that doesn't raise an exception can set a flag,
and code after the read() can test it.

Under the proposed scheme, the signal handler has to
be made to raise an exception so that the read will be
broken out of in the EINTR case.

But what happens if the read returns *without* an EINTR?
The signal handler will still raise an exception, which is
either going to clobber the partial return value or mess
up the code that does something with it.

-- 
Greg


More information about the Python-Dev mailing list