我注意到在sigaction的定义中,sa_sigaction回调,最后一个参数是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); }
这有点表明您可以将用户参数传递给sa_sigaction处理程序.
但是,我一直无法找到这样的例子.
有谁知道你是否可以将参数传递给sigaction回调函数?
你有一个简单的例子吗?
解决方法
不幸的是不是虽然签名是无效*,但它实际上是一个ucontext_t.从单UNIX规范:
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