Linux 信号带有额外的信息参数

发布于 2024-10-09 14:55:12 字数 218 浏览 0 评论 0原文

我想在 sa_sigaction 处理程序的回调中获得一些额外的信息,但这似乎不可能。

所以我想知道你是否可以建议我替代方案。基本要求:

  1. 函数 A 引发一个信号/事件,其中包含指向处理该事件的 struct
  2. Handler 函数的指针。
  3. 处理函数只会在事件发生时调用,并且等待事件的循环(如 select() 中)是不可取的。

I was to have some extra information in the callback to sa_sigaction handler, it does not seems possible.

So I was wondering if you could suggest me alternatives. Basic requirements:

  1. Function A raises an signal/event with a pointer to a struct
  2. Handler function tackles the event.
  3. The handler function would only be called on an event and a loop to wait for the event, as in select() , is undesirable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天煞孤星 2024-10-16 14:55:12

像这样 ?

    int sigqueue(pid_t to_pid, int signr, const union sigval pointer_or_int);

另一端:

   int signr=int sigwaitinfo(const sigset_t *set, siginfo_t *info);

警告!:通过引用传递可能无法在不同的地址/进程空间之间工作(我自己还没有测试过),所以首先在同一进程的线程之间测试这个......

祝你好运:-)

like this ?

    int sigqueue(pid_t to_pid, int signr, const union sigval pointer_or_int);

and on the other end:

   int signr=int sigwaitinfo(const sigset_t *set, siginfo_t *info);

Warning!: passing by reference might not work between different address/process spaces (I haven't tested this myself yet) so first test this between threads of the same process....

good luck :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文