[Python-Dev] Re: Signal-resistant code (was: Two random and nearly unrelated ideas)

Guido van Rossum guido@python.org
Thu, 05 Sep 2002 14:19:02 -0400


> >  - Macro: AC_SYS_RESTARTABLE_SYSCALLS
> >      If the system automatically restarts a system call that is
> >      interrupted by a signal, define `HAVE_RESTARTABLE_SYSCALLS'.
> 
> The name of this macro is misleading. It doesn't check whether system calls
> are restartABLE but whether they are restartED automatically by libc. It 
> forks a subprocess that sends a signal to the parent. The parent waits for
> the child and checks if the wait() was interrupted.
> 
> If this macro is defined you will never get EINTR so there's no need to
> worry about this. If it isn't defined you need to restart system calls 
> yourself.

This was a feature introduced by BSD Unix in a distant past, as a
change from v7 Unix (which had only the EINTR behavior).  For b/w
compatibility, BSD had a system call to disable the restart feature.
I'm guessing that over the years the feature has been found less than
helpful, so POSIX defaults to off.  POSIX sigaction() has a flag
SA_RESTART to enable restarting.

--Guido van Rossum (home page: http://www.python.org/~guido/)