[Python-Dev] Re: Signal-resistant code

Paul Svensson paul-python@svensson.org
Thu, 5 Sep 2002 17:08:54 -0400 (EDT)

On Thu, 5 Sep 2002, Oren Tirosh wrote:

>So what are the three problems of signals?

>Two - Interruptible system calls.  If all Python I/O calls are wrapped
>inside restarting wrappers this should be solved. If the system's libc
>wraps them it can be disabled by SA_RESTART (posix) or siginterrupt (BSD).
>On some systems read and recv return a short buffer instead of EINTR. This
>can be safely ignored because it only happens for pipes and sockets where
>this is a valid result. AFAIR it's guaranteed not to happen on regular
>files so we won't be tricked into believing they reached EOF.  Are there
>any systems where system calls are interruptible but not restartable
>in any way without data loss?

I don't see any guarantee against short reads in my documentation (Linux,
HP-UX); indeed both state explicitly that only a 0 return from read()
indicates EOF.