From: Thomas Orgis <thomas@orgis.org>
To: Alejandro Colomar <alx@kernel.org>
Cc: <linux-man@vger.kernel.org>
Subject: SA_RESTART and friends as XSI extensions to POSIX.1-2001 < XOPEN_SOURCE >= 600
Date: Wed, 14 Feb 2024 09:57:07 +0100 [thread overview]
Message-ID: <20240214095707.1824c25c@plasteblaster> (raw)
[-- Attachment #1: Type: text/plain, Size: 3585 bytes --]
Hi,
I had trouble compiling code with -std=c99 and needed some time to
figure out why the use of SA_RESTART did not work with
#define _POSIX_C_SOURCE 200112L
despite the man page of sigaction suggesting that this would be the
correct feature test macro. Searching around the net reveals that this
is a known discrepancy between man pages and glibc since at least 11
years. People stumble over this, learn, forget. Please let's document
it this time;-)
sigaction(2) claims this:
POSIX.1-2001 added
.BR SA_NOCLDSTOP ,
.BR SA_NOCLDWAIT ,
.BR SA_NODEFER ,
.BR SA_ONSTACK ,
.BR SA_RESETHAND ,
.BR SA_RESTART ,
and
.BR SA_SIGINFO .
All of these are extensions (XSI) to POSIX and need _XOPEN_SOURCE 600.
Quoting https://pubs.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html
(thanks to https://unix.stackexchange.com/questions/613139/sigaction-sa-flags-and-posix-1-2001-base-spec):
The following shall be declared as constants:
SA_NOCLDSTOP
[CX] [Option Start] Do not generate SIGCHLD when children stop [Option End]
[XSI] [Option Start] or stopped children continue. [Option End]
[...]
SA_ONSTACK
[XSI] [Option Start] Causes signal delivery to occur on an alternate stack. [Option End]
SA_RESETHAND
[XSI] [Option Start] Causes signal dispositions to be set to SIG_DFL on entry to signal handlers. [Option End]
SA_RESTART
[XSI] [Option Start] Causes certain functions to become restartable. [Option End]
SA_SIGINFO
[XSI] [Option Start] Causes extra information to be passed to signal handlers at the time of receipt of a signal. [Option End]
SA_NOCLDWAIT
[XSI] [Option Start] Causes implementations not to create zombie processes on child death. [Option End]
SA_NODEFER
[XSI] [Option Start] Causes signal not to be automatically blocked on entry to signal handler. [Option End]
[and not mentioned in the man page, not relevant?]
SS_ONSTACK
[XSI] [Option Start] Process is executing on an alternate signal stack. [Option End]
SS_DISABLE
[XSI] [Option Start] Alternate signal stack is disabled. [Option End]
MINSIGSTKSZ
[XSI] [Option Start] Minimum stack size for a signal handler. [Option End]
SIGSTKSZ
[XSI] [Option Start] Default size in bytes for the alternate signal stack. [Option End]
As a related bit, I noticed that feature_test_macros(7) is a bit
misleading here:
.IP \[bu]
Defining
.B _XOPEN_SOURCE
with a value of 600 or greater produces the same effects as defining
.B _POSIX_C_SOURCE
with a value of 200112L or greater.
As written later on the same page, X_OPEN_SOURCE 600 triggers a superset
of POSIX, not the same effects.
I hope these rather small changes can be made by a committer without
lengthy discussion of patches. I suggest something along this, without
formatting details that I'd get wrong:
sigaction(2):
POSIX.1-2001 added
.BR SA_NOCLDSTOP ,
.BR SA_NOCLDWAIT ,
.BR SA_NODEFER ,
.BR SA_ONSTACK ,
.BR SA_RESETHAND ,
.BR SA_RESTART ,
and
.BR SA_SIGINFO ,
as XSI extensions (define _XOPEN_SOURCE to at least 600 to use).
feature_test_macros(7):
.IP \[bu]
Defining
.B _XOPEN_SOURCE
with a value of 600 or greater includes the effects of defining
.B _POSIX_C_SOURCE
with a value of 200112L or greater, adding the X/Open System Interfaces Extension (XSI).
Alrighty then,
Thomas
--
GPG public key 60D5CAFE: https://thomas.orgis.org/public_key
Fingerprint: D021 FF8E CF4B E097 19D6 1A27 231C 4CBC 60D5 CAFE
And despite all of you, I'm still doing it. Yes, I do write Perl code.
[-- Attachment #2: Firma digital OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next reply other threads:[~2024-02-14 8:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-14 8:57 Thomas Orgis [this message]
2024-02-25 11:41 ` Status of SA_NOCLDWAIT in POSIX.1 (was: SA_RESTART and friends as XSI extensions to POSIX.1-2001 < XOPEN_SOURCE >= 600) Alejandro Colomar
2024-02-25 11:53 ` [PATCH 0/2] sigaction.2: HISTORY: Document history of POSIX constants more accurately Alejandro Colomar
2024-02-25 11:53 ` [PATCH 1/2] sigaction.2: HISTORY: SA_NOCLDSTOP wasn't added in POSIX.1-2001 Alejandro Colomar
2024-02-27 18:12 ` Thomas Orgis
2024-02-27 21:15 ` Alejandro Colomar
2024-02-25 11:53 ` [PATCH 2/2] sigaction.2: HISTORY: Some constants are or were XSI extensions Alejandro Colomar
2024-02-27 18:14 ` Thomas Orgis
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=20240214095707.1824c25c@plasteblaster \
--to=thomas@orgis.org \
--cc=alx@kernel.org \
--cc=linux-man@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 read-only IMAP folder(s) and NNTP newsgroup(s).