Is there any way to create a user defined signal i

2020-02-09 09:00发布

Is there any way to create a user defined signals in 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.

标签: c linux signals
5条回答
ゆ 、 Hurt°
2楼-- · 2020-02-09 09:45

You can use USR1 and USR2 for this kind of thing.

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.

查看更多
beautiful°
3楼-- · 2020-02-09 09:57

You can compile your own kernel with special signals :)

查看更多
倾城 Initia
4楼-- · 2020-02-09 10:03

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. The former have additional realtime queueing support; the latter don't. Simply choose one to use.

查看更多
倾城 Initia
5楼-- · 2020-02-09 10:05

There are the USR1 and USR2 signals designed for user defined purposes.

查看更多
乱世女痞
6楼-- · 2020-02-09 10:06

You can't add or register your own SIGWHATEVER.

See sigset_t, it is fixed size. See valid_signal() beartraps.

查看更多
登录 后发表回答