Can you pass an argument to sigaction?

linux

Solution

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

Problem

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?

Original source