Can you pass the sigaction argument?

I noticed in the definition of sigaction, sa_sigaction callback, the last argument is 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 will mean that you can pass the user argument to the sa_sigaction handler.

However, I could not find an example of this.

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

+7
linux
source share
1 answer

Unfortunately not. Although the signature is void *, it is actually ucontext_t. From the Single UNIX specification:

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

+13
source share

All Articles