linux – 你能把一个参数传递给sigaction吗?

前端之家收集整理的这篇文章主要介绍了linux – 你能把一个参数传递给sigaction吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我注意到在sigaction的定义中,sa_sigaction回调,最后一个参数是void *. @H_301_2@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

猜你在找的Linux相关文章