In sigaction
manpage it's written :
sa_sigaction
also specifies the action to be associated with signum
.
This function receives the signal number as its first argument, a
pointer to a siginfo_t
as its second argument and a pointer to a ucon-
text_t (cast to void*
) as its third argument.
So we can pass arguments to the signal handler (throught void*
), but I
can't find the way.
Is there no way to put it anywhere?
Example :
struct ping_val
{
int data1;
int data2;
};
void ping(int sig, siginfo_t *siginf, void *ptr)
{
// ....
}
int main()
{
struct sigaction sa_ping;
ping_val foo;
foo.data1 = 3;
foo.data2 = 4;
sa_ping.sa_sigaction = ping;
sigemptyset(&sa_ping.sa_mask);
sa_ping.sa_flags = 0;
sigaction(SIGALRM, &sa_ping, NULL);
// ....
}
Where I can pass foo
structure value in argument in ping (with a cast in struct *
)???