1834165 Members
2880 Online
110064 Solutions
New Discussion

Re: Unix Signals

 
SOLVED
Go to solution

Unix Signals

Hi there,

What is the maximum number of signals? 2? Where can I find information on this?

Thanks,
Kym
16 REPLIES 16
Anu Mathew
Valued Contributor

Re: Unix Signals

Hi Kym,


On HP-UX, 44 types of signals. Do a kill -l to see the details.

Hope this helps,

~AM
Ralph Grothe
Honored Contributor

Re: Unix Signals

As said a "kill -l" lists signals as implemented under your Unix derivative.

Apart from that HP-UX comes with a nice more explicatory manpage

man 5 signal
Madness, thy name is system administration

Re: Unix Signals

Thanks! I didn't phrase the question correctly. For my application, I need three signals. I am currently using SIGUSR1 and SIGUSR2 (with signal()). What signal number can I use for the third signal, fourth, and max number of signals available for user app?

Where can I get the definition of the signal numbers from kill -l?

Thanks again,
Kym





Sridhar Bhaskarla
Honored Contributor

Re: Unix Signals

Hi Kym,

Have a look at /usr/include/sys/signal.h file. All the signals are defined there.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try

Re: Unix Signals

Sri,

Thanks! Is there only 2 user defined signals? (SIGUSR1 and SIGUSR2). I need three for my application. How can I get a third user defined signal?

Thanks,
Kym
A. Clay Stephenson
Acclaimed Contributor

Re: Unix Signals

You seem to be suffering from a basic misunderstanding of signals and signal handling.
Other than those which cannot be caught (9 - SIGKILL, e.g.), the others are available for your use. Any signal handler (trap) you use will replace the default handler.

For example, it is very common to use SIGINT (2), to trap Ctrl-C keypresses or it is very common to use SIGHUP (1) to reread configuration files even though the default behavior is to exit the program.
If it ain't broke, I can fix that.
Sridhar Bhaskarla
Honored Contributor

Re: Unix Signals

Hi Kym,

I am having hardtime understanding what your requirement is. What exactly are you trying to do?.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try

Re: Unix Signals

In my HPUX device driver, I provided an interface that would signal to the calling process/ user's application when something has completed, i.e. data transmitted successfully. I save a reference to the calling process, and a signal number.
I use psignal() to signal to the calling process.

In my test application that uses the interface to the HPUX device driver, I use SIGUSR1 and SIGUSR2. I need another user defined signal number. Is there a SIGUSR3 like user defined signal number? I looked at the header files for signals both on Solaris and HPUX, but was not able to find a third user defined signal. Is there only two user defined signals in UNIX, i.e. SIGUSR1 and SIGUSR2? Is there a link where I can get more information on this?

Thanks again,
Kym
James R. Ferguson
Acclaimed Contributor

Re: Unix Signals

Hi Kym:

Aside from that which has already been provided, the man pages for 'signal(5)' offer some additional information.

Regards!

...JRF...
Sridhar Bhaskarla
Honored Contributor

Re: Unix Signals

Kym,

As far as my knowledge goes, you cannot have another user defined signal other than what you already have in signal.h.

However, unless you are trapping all the signals in your code, you could use any of the unused signals to achieve what you want.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Sridhar Bhaskarla
Honored Contributor

Re: Unix Signals

Kym,

As far as my knowledge goes, you cannot have another user defined signal other than what you already have in signal.h.

However, unless you are trapping all the signals in your code, you could use any of the unused signals to achieve what you want.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
A. Clay Stephenson
Acclaimed Contributor

Re: Unix Signals

It is very unusual for a device driver to signal a user process; if anything, I would look into using only one signal for any event and then the user process would have a handler that does an ioctl() to inquire what the message/alert is. That method would allow an open-ended number of different kinds of events.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Unix Signals

It is very unusual for a device driver to signal a user process; if anything, I would look into using only one signal for any event and then the user process would have a handler that does an ioctl() to inquire what the message/alert is. That method would allow an open-ended number of different kinds of events.
If it ain't broke, I can fix that.

Re: Unix Signals

A. Clay,

Thanks! I like your suggestion for an alternative. I inherited the current signal mechanism :(.

I tried creating a third signal number other than the defines in signal.h, and it didn't work. It seems like there is only 2 user defined signals.

Thanks,
Kym







Adam J Markiewicz
Trusted Contributor

Re: Unix Signals

Hi Kym

Check Clays suggestion very carefully, as this is extremally good advice. (After a while you might end up with need for another signal, and then another... Implementing open interface is very, very useful, especially for task, like driver).

However, if preparing a driver and DEFFINETLY NEEDING more signals I would consider reusage of XWindows signals for exaple, as theses are unlikely to be used. SIGWINCH is a good one, unless your driver is using an XWindow for some reason.


Good luck
Adam
I do everything perfectly, except from my mistakes
Adam J Markiewicz
Trusted Contributor

Re: Unix Signals

Ooops.

Considering the direction of the signal thransmission it is the client who shouldn't use XWindows, not the driver, of course.

Sorry for the confusion.
Adam
I do everything perfectly, except from my mistakes