加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

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

发布时间:2020-12-14 02:21:33 所属栏目:Linux 来源:网络整理
导读:我注意到在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);} 这有点表明您可以将用
我注意到在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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读