I'm in the process of transitioning my program's signal handling from signal() to sigaction().
According to the UNIX spec a struct sigaction
should have at least 4 members; sa_handler
, sa_mask
, sa_flags
and sa_sigaction
.
When I define a structure as follows, everything appears to be normal.
...
#include <signal.h>
...
struct sigaction sa;
But when I attempt to assign a value to sa_handler
, the member does not exist. Instead I see this:
I looked through my signal.h
and bits/sigaction.h
(neither of which has 1092 lines in case you're wondering) and nothing seems amiss.
I also tried using this member name as is, but the compiler complains with
incomparable types when assigning to type 'union ' from type 'void (*)(int)'
This makes me think there is something wrong with how my compiler/IDE is handling the structure's definition, but that is above my head on how to diagnose.
Any help or suggestions would be appreciated.
System info:
- Debian 8
- linux 3.16.0-4-amd64
- gcc 4.9.2 (Debian 4.9.2-10)
- eclipse-cdt 3.8.1
Update - 8/3/2016
Found these two threads here and here, that suggested defining the preprocessor symbols _POSIX_C_SOURCE
and _XOPEN_SOURCE
respectively. I defined each (one at a time) and both 'fixed' the incompatable type issue (I successfully assigned a value to sa.__sigaction_handler). But they both also broke my software's ability to use type intptr_t (used for thread function management) and were removed for that reason.
Doing this fixed the issue, however. I can now assign a variable to sa.sa_handler without the compiler throwing an error. The IDE still shows it as a non-existent member (same as image linked above) but that is a minor issue IMHO.