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.
In the list of signals defined in a linux system, there are two signals stated as User Defined signals ( SIGUSR1 and SIGUSR2 ). Other signals will be raised or caught in specific situations, but SIGUSRs are left for user application's use.
Generation A signal is generated by a process via the kernel. Whichever generates the signal addresses process to a particular process. With the help of the process number, the signal is represented, and it does not contain any additional data or arguments. So, signals are lightweight.
Thanks! The signals are defined in the POSIX standard (IEEE Std 1003.1-2001), and implemented in the kernel. Unless you want to break compatibility with all other Unices I'd advise using other methods of IPC, eg messages via shared memory. Unfortunately, there is no way to add signals.
The SIGUSR1 and SIGUSR2 signals are set aside for you to use any way you want. They're useful for simple interprocess communication, if you write a signal handler for them in the program that receives the signal. There is an example showing the use of SIGUSR1 and SIGUSR2 in Signaling Another Process.
You can compile your own kernel with special signals :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With