public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Ornati <ornati@fastwebnet.it>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Lack of Documentation about SA_RESTART...
Date: Mon, 11 Jul 2005 12:32:37 +0200	[thread overview]
Message-ID: <20050711123237.787dfcde@localhost> (raw)

The documentation (man pages & info libc) doesn't cover well interaction
between various syscalls and SA_RESTART flag of sigaction()... I wonder
why!

	> MAN SIGACTION <

"SA_RESTART
Provide behaviour compatible with BSD signal semantics by
making certain system calls restartable across signals."

	certain?!? :-O!


	> INFO LIBC <

"   One important exception is `EINTR' (*note Interrupted Primitives::).
Many stream I/O implementations will treat it as an ordinary error,
which can be quite inconvenient.  You can avoid this hassle by
installing all signals with the `SA_RESTART' flag."


" -- Macro: int SA_RESTART
     This flag controls what happens when a signal is delivered during
     certain primitives (such as `open', `read' or `write'), and the
     signal handler returns normally.  There are two alternatives: the
     library function can resume, or it can return failure with error
     code `EINTR'."

	Ok, "info libc" is a bit better.


But what I'm looking for is a list of syscalls that are automatically
restarted when SA_RESTART is set, and especially in what conditions.

For example: read(), write(), open() are obviously restarted, but even
on non-blocking fd?
And what about connect() and select() for example?

There are a lot of syscalls that can fail with "EINTR"! What's the
advantage of using SA_RESTART if one doesn't know what syscalls are
restarted?

One should always check for "EINTR" or use "TEMP_FAILURE_RETRY()" macro
as suggested in "info libc" !


Looking at the source I can easly see that a syscall is retarted when it
returns "-ERESTARTSYS" and SA_RESTART flag is set. Should I look at the
code for every syscall / particular condition?


Example of behavior: according to source code it seems that "connect()"
(the "net/ipv4/af_inet.c : inet_stream_connect()" implementation)
returns -ERESTARTSYS if interrupted, but if the socket is in
non-blocking mode it returns -EINTR.


SUMMARY:

1) there is a reason for this lack of documentation?

2) what can I safely assume about syscalls restart when using SA_RESTART
flag?


Bye,

-- 
	Paolo Ornati
	Linux 2.6.12.2 on x86_64

             reply	other threads:[~2005-07-11 10:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-11 10:32 Paolo Ornati [this message]
2005-07-11 14:34 ` Lack of Documentation about SA_RESTART Theodore Ts'o
2005-07-12  3:30   ` Philippe Troin
2005-07-12  8:43     ` Paolo Ornati
2005-07-12  8:38   ` Paolo Ornati
2005-07-12 10:10     ` Paolo Ornati
2005-07-12 12:04     ` Theodore Ts'o
2005-07-12 15:25       ` Paolo Ornati
2005-07-12 18:16         ` Theodore Ts'o
2005-07-13  7:45           ` Paolo Ornati
2005-07-24  0:30   ` Linus Torvalds
2005-07-24  7:28     ` Paolo Ornati
2005-07-24 14:56     ` Theodore Ts'o
2005-07-25  8:02       ` Paolo Ornati

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050711123237.787dfcde@localhost \
    --to=ornati@fastwebnet.it \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox