Philip Guenther
2012-09-10 19:40:09 UTC
XSH then specifies the effect of the SA_RESTART flag in the
sigaction() page like this:
SA_RESTART This flag affects the behavior of interruptible functions;
that is, those
specified to fail with errno set to [EINTR]. If set, and a
function specified
as interruptible is interrupted by this signal, the
function shall restart and
shall not fail with [EINTR] unless otherwise specified. If
an interruptible
function which uses a timeout is restarted, the duration of
the timeout
following the restart is set to an unspecified value that
does not exceed
the original timeout value. If the flag is not set,
interruptible functions
interrupted by this signal shall fail with errno set to [EINTR].
Okay, so SA_RESTART handling is "opt out" for functions. How can I
determine whether a given function is opting out?
The one clear text is the page for select() and pselect(), which says:
[EINTR] The function was interrupted before any of the selected events
occurred and
before the timeout interval expired.
If SA_RESTART has been set for the interrupting signal, it is
implementation-
defined whether the function restarts or returns with [EINTR].
That's the only page which explicitly references SA_RESTART. Does
that mean it's the only one which is opting out?
Based on the manpages on at least Solaris, FreeBSD, and OpenBSD, I
would expect several other functions to be unaffected by SA_RESTART:
poll(), sigsuspend(), nanosleep(), and clock_nanosleep() are the
obvious ones. Testing shows that they are indeed unaffected on those
three systems as well as on Linux.
Furthermore, on at least Solaris, FreeBSD, and OpenBSD, connect() and
open("/path/to/fifo") are also unaffected by SA_RESTART and return
EINTR. On Linux 2.6.18, those do appear to restart.
Finally, on Solaris the accept() call is also not restarted, while it
is on FreeBSD, OpenBSD, and Linux.
So, is there something specific in the specifications for poll(),
sigsuspend(), nanosleep(), and clock_nanosleep() that indicates that
they don't restart?
Should there be something in the specifications for open(), connect(),
and accept() that either permits or requires it them to not restart?
Philip Guenther
sigaction() page like this:
SA_RESTART This flag affects the behavior of interruptible functions;
that is, those
specified to fail with errno set to [EINTR]. If set, and a
function specified
as interruptible is interrupted by this signal, the
function shall restart and
shall not fail with [EINTR] unless otherwise specified. If
an interruptible
function which uses a timeout is restarted, the duration of
the timeout
following the restart is set to an unspecified value that
does not exceed
the original timeout value. If the flag is not set,
interruptible functions
interrupted by this signal shall fail with errno set to [EINTR].
Okay, so SA_RESTART handling is "opt out" for functions. How can I
determine whether a given function is opting out?
The one clear text is the page for select() and pselect(), which says:
[EINTR] The function was interrupted before any of the selected events
occurred and
before the timeout interval expired.
If SA_RESTART has been set for the interrupting signal, it is
implementation-
defined whether the function restarts or returns with [EINTR].
That's the only page which explicitly references SA_RESTART. Does
that mean it's the only one which is opting out?
Based on the manpages on at least Solaris, FreeBSD, and OpenBSD, I
would expect several other functions to be unaffected by SA_RESTART:
poll(), sigsuspend(), nanosleep(), and clock_nanosleep() are the
obvious ones. Testing shows that they are indeed unaffected on those
three systems as well as on Linux.
Furthermore, on at least Solaris, FreeBSD, and OpenBSD, connect() and
open("/path/to/fifo") are also unaffected by SA_RESTART and return
EINTR. On Linux 2.6.18, those do appear to restart.
Finally, on Solaris the accept() call is also not restarted, while it
is on FreeBSD, OpenBSD, and Linux.
So, is there something specific in the specifications for poll(),
sigsuspend(), nanosleep(), and clock_nanosleep() that indicates that
they don't restart?
Should there be something in the specifications for open(), connect(),
and accept() that either permits or requires it them to not restart?
Philip Guenther