From: Glynn Clements <glynn.clements@virgin.net>
To: Cesar Rincon <crincon@et.com.mx>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: accept() and signals
Date: Thu, 1 Apr 2004 01:58:48 +0100 [thread overview]
Message-ID: <16491.26952.611460.119076@cerise.nosuchdomain.co.uk> (raw)
In-Reply-To: <20040331235424.GE24581@et.com.mx>
Cesar Rincon wrote:
> > The default behaviour of signal() in GNU libc 2.x is the BSD
> > behaviour, i.e. interrupted system calls are automatically
> > restarted, and the handler isn't reset upon receipt of a signal. If
> > you want system calls such as accept() to be interrupted, you should
> > use sigaction() without the SA_RESTART flag.
>
> Which works perfectly, thank you very much.
>
> > More generally, the safest approach is to always use sigaction()
> > rather than to assume a particular behaviour from signal().
>
> And it says that much in the manual, duh. It's just that I was using
> Spanish-translated dev manpages, which are, now I know, ahem, a bit
> outdated. E.g., sigaction(2) says that SA_RESETHAND is the default
> behaviour of signal()...
It used to be. Versions of libc based upon GNU libc 1.x (i.e. up to
and including libc-5) used the SysV semantics by default. It was
changed because:
1. Resetting the signal disposition (i.e. the SysV semantics or the
SA_RESETHAND flag) is the wrong thing to do more often than it is the
right thing to do.
2. Interrupting system calls (i.e. the SysV semantics) is probably the
wrong thing to do at least as often as it is the right thing to do.
3. Interrupting system calls when the programmer wasn't expecting it
is arguably worse than not interrupting them when the programmer was
expecting it. In the latter case, the programmer will probably
discover (and presumably fix) the problem fairly quickly. In the
former case, the program will survive cursory testing but may fail in
actual use.
Actually, my signal(2) manpage (English, supplied with RedHat 6.2,
which uses GNU libc 2.1.3) says:
Unlike on BSD systems, signals under Linux are reset to
their default behavior when raised. However, if you
include <bsd/signal.h> instead of <signal.h> then signal
is redefined as __bsd_signal and signal has the BSD seman
tics. Both versions of signal are library routines built
on top of sigaction(2).
Which is incorrect. So it may not be just the translation which is
outdated.
A large part of the problem is that the GNU project officially favours
texinfo documentation over traditional manual pages. The manpages for
most of the libc functions were written by third parties (and some of
them are taken directly from BSD).
--
Glynn Clements <glynn.clements@virgin.net>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2004-04-01 0:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-31 20:59 accept() and signals Cesar Rincon
2004-03-31 22:21 ` Glynn Clements
2004-03-31 23:54 ` Cesar Rincon
2004-04-01 0:58 ` Glynn Clements [this message]
2004-04-01 3:08 ` Cesar Rincon
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=16491.26952.611460.119076@cerise.nosuchdomain.co.uk \
--to=glynn.clements@virgin.net \
--cc=crincon@et.com.mx \
--cc=linux-c-programming@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;
as well as URLs for NNTP newsgroup(s).