Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

linux

signals

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.

like image 810
RajSanpui Avatar asked Apr 21 '11 08:04

RajSanpui


People also ask

What are user defined signals in Linux?

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.

How signals are generated in Linux?

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.

Can you add new signal types in Linux?

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.

What is SIGUSR1 in Linux?

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.


1 Answers

You can compile your own kernel with special signals :)

like image 77
Florian Avatar answered Sep 20 '22 02:09

Florian