I'm doing an application that uses Linux signals. Searching through the internet, I came across the following struct declaration
1 2 3 4 5 6 7 8 9
struct sigaction {
union {
void (*__sa_handler)(int);
void (*__sa_sigaction)(int, struct __siginfo *, void *);
} __sigaction_u; /* signal handler */
int sa_flags; /* see signal options below */
sigset_t sa_mask; /* signal mask to apply */
};
My question is: What does this mean? . Of course, i'm not talking about what the struct is for, but instead, about its syntax, and the meaning of all the elements here. What is this? :
This void (*__sa_handler)(int); declares a variable called "__sa_handler" that is a pointer to a function that takes one int as an argument and returns void.
A union stores all of its members at the same location in memory.