SA_RESTART and friends as XSI extensions to POSIX.1-2001 < XOPEN_SOURCE >= 600

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: pgpAQKwxxa39p.pgp
Description: Firma digital OpenPGP


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux