This is an excerpt from SIGACTION(2):
POSIX.1-1990 specified only SA_NOCLDSTOP. POSIX.1-2001 added SA_NOCLDSTOP, SA_NOCLDWAIT, SA_NODEFER, SA_ONSTACK, SA_RESETHAND, SA_RESTART, and SA_SIGINFO. Use of these latter values in sa_flags may be less portable in applications intended for older UNIX implementations. And from FEATURE_TEST_MACROS(7):
_POSIX_C_SOURCE · (Since glibc 2.3.3) The value 200112L or greater additionally exposes definitions corresponding to the POSIX.1-2001 base specification (excluding the XSI extension). This value also causes C95 (since glibc 2.12) and C99 (since glibc 2.10) features to be exposed (in other words, the equivalent of defining _ISOC99_SOURCE). But in reality, the flags added in 2001 spec is not exposed when the value 200112L is used. So, the following code does not compile. I tried glibc and uclibc.
#define _POSIX_C_SOURCE 200112L #include <string.h> #include <signal.h> #include <unistd.h> static int ret = 1; void handle_signal (const int s) { ret = 0; } int main (const int argc, const char **args) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_flags = SA_RESETHAND; sa.sa_sigaction = handle_signal; sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); pause(); return ret; } What am I missing here? Are the flags not 2001 base spec? Are they an extension? Or is this just a bug in Linux libc implementations?
__USE_XOPEN_EXTENDED(so you may need to#define _XOPEN_SOURCE_EXTENDEDinstead)_POSIX_C_SOURCE=200112Lmacro define wouldn't exposeSA_*flags". Thank you.constite. As to your problem, good luck finding a POSIX historian who would confirm you whetherSA_RESETHANDhas become standard 20 or 15 years ago. In susv3 aka POSIX-1.2001SA_RESTARTHANDstill appears marked asXSI(X/Open System Interface). Assuming that that (googled out) page is right.