[Python-Dev] Re: Signal-resistant code (was: Two random and nearly unrelated ideas)
Oren Tirosh
oren-py-d@hishome.net
Thu, 5 Sep 2002 05:30:02 -0400
On Wed, Sep 04, 2002 at 05:21:44PM -0400, François Pinard wrote:
> I'm not fully familiar with all the details of this problem, it surely has
> been in the air for quite a long time now (I might have first heard of it
> while Taylor UUCP was being developed). It might be dependent on the
> underlying system. If I'm not mistaken, this is Ian Taylor who introduced the
> following Autoconf macro:
>
>
> - 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.
If a platform really has interruptible I/O calls that cannot be continued or
restarted without data loss there is no way to use signal handlers on that
system. I doubt that such totally broken platforms are common these days.
> In GNU file utilities (now merged within the new GNU coreutils), Jim Meyering
> uses restart wrappers for many I/O functions, so the idea of wrappers has been
> maturing for a while, and is used in basic, heavily used programs.
I'll check the sources.
Oren