Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

So why only two signals?

share|improve this question
add comment

2 Answers 2

up vote 7 down vote accepted

Historically, Unix had only these two signals, but modern systems have the real-time signals SIGRTMIN...SIGRTMAX.

Due to the wacky and unportable semantics of the signal APIs, there is almost no use case where signals would be preferrable over other communication mechanisms like pipes. Therefore, allocating a new signal number has never been seen as necessary.

share|improve this answer
    
Thanks. In my case I handle SIGUSR1 for reconfiguration. It means when the admin wants to change the configuration of my running process, it changes the config file and sends a SIGUSR1 to my PID (easier to use a pipe here). And I use SIGUSR2 for clean process shutdown. It hadn't got necessary for me to use a signal other than these two, but some runtime features could be implemented by handling other user defined signals! –  saeedn Sep 19 '12 at 19:32
1  
@saeedn Why don't you use SIGTERM for clean process shutdown? That's what it's for. Many other servers use SIGHUP (which is only otherwise meaningful on an interactive process) as a signal to reload configuration files, so you might consider that. –  Random832 Sep 19 '12 at 21:02
    
@Random832 You're right, I know what you say. But the problem I was thinking about was that what if I ran out of my 31 choices of signals? –  saeedn Sep 19 '12 at 22:10
    
Where can I get more info about the SIGRTMIN...SIGRTMAX signals? Where are they defined when they are used? –  Strubbl May 17 '13 at 7:27
add comment

Signals only provide a primitive means of communication. In particular, there's no way to attach any information to them. The recipient only knows the signal number, not the identity of the sender. Multiple signals can be conflated into one. Given all these restrictions, there aren't that many useful purposes for signals.

For more complex purposes, use more complex means of interactions, such as pipes or sockets.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.