tags:

views:

136

answers:

1

I noticed in the definition of the sigaction, sa_sigaction callback, the last argument is a void *.

struct sigaction {
    void (*sa_handler)(int);
    void (*sa_sigaction)(int, siginfo_t *, void * );
    sigset_t sa_mask;
    int sa_flags;
    void (*sa_restorer)(void);
}

This would sort of indicate that you can pass an user argument to the sa_sigaction handler.

However, I have been unable to find an example of this.

Does anyone know if you can pass an argument to the sigaction callback function? and Do you have have a simple example?

+3  A: 

Unfortunately not. While the signature is a void *, it's actually a ucontext_t. From the Single UNIX Specification:

the third argument can be cast to a pointer to an object of type ucontext_t to refer to the receiving process' context that was interrupted when the signal was delivered

R Samuel Klatchko
And here's an example: http://www.linuxjournal.com/files/linuxjournal.com/linuxjournal/articles/063/6391/6391l3.html
codelogic
A link to the relevant page in the online SUSv3 specification: http://www.opengroup.org/onlinepubs/009695399/functions/sigaction.html
ephemient
that's unfortunate :(
simon