开发者

Can you pass an argument to sigaction?

开发者 https://www.devze.com 2022-12-13 00:49 出处:网络
I noticed in the definition of the sigaction, sa_sigaction callback, the last argument is a void *. struct sigaction {

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,开发者_JAVA百科 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消