简体   繁体   English

有没有办法在Linux中创建用户定义的信号?

[英]Is there any way to create a user defined signal in Linux?

Is there any way to create a user defined signals in Linux? 有没有办法在Linux中创建用户定义的信号? My signal (signal number) should not match any of the existing signal numbers. 我的信号(信号编号)不应与任何现有信号编号匹配。

In other words, i want to create my own unique signal, which will be registered and caught by my handler. 换句话说,我想创建我自己的唯一信号,它将由我的处理程序注册和捕获。

Is it possible? 可能吗? If yes, how? 如果有,怎么样?

Thanks in advance. 提前致谢。

SIGRTMIN through SIGRTMAX (these are not normally constants but macros which expand to functions evaluated at runtime) are available for whatever use you like, as are SIGUSR1 and SIGUSR2 . SIGRTMIN通过SIGRTMAX (这些通常不是常量,但扩展为在运行时计算的函数的宏)可用于您喜欢的任何用途,如SIGUSR1SIGUSR2 The former have additional realtime queueing support; 前者有额外的实时排队支持; the latter don't. 后者没有。 Simply choose one to use. 只需选择一个即可使用。

You can't add or register your own SIGWHATEVER. 您无法添加或注册自己的SIGWHATEVER。

See sigset_t , it is fixed size. sigset_t ,它是固定大小的。 See valid_signal() beartraps. 请参阅valid_signal() beartraps。

您可以使用特殊信号编译自己的内核:)

USR1USR2信号设计用于用户定义的目的。

You can use USR1 and USR2 for this kind of thing. 您可以使用USR1和USR2进行此类操作。

If that's not enough, you can emulate signal like behaviour by having your application listen on a socket which external apps can send messages to. 如果这还不够,您可以通过让应用程序侦听外部应用程序可以向其发送消息的套接字来模拟信号行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM