Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you pass an argument to sigaction?

Tags:

linux

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?

like image 357
simon Avatar asked Dec 03 '09 22:12

simon


1 Answers

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

like image 104
R Samuel Klatchko Avatar answered Oct 18 '22 16:10

R Samuel Klatchko