Reputation: 2784
In man 7 signal
it shows that SIGUSR1 as SIGUSR1 30,10,16 Term User-defined signal 1
. If i use SIGUSR1 in my C code, i get the value 10. Is there any way to access the other values 30 & 16? Is it okay to use them explicitly in my signal handler like
if(signo == 16)
{
printf("SIGUSR1 type 2 received\n");
}
Edit:In my code , there is a case statement that uses SIGUSR1 already. I need one more custom signal . I know there are RTSIGNALS and other options. But i wanted to know why they specify 16,30 in man page and never provide a way to use it.
Upvotes: 2
Views: 6899
Reputation: 16406
The manual says
Several signal numbers are architecture dependent, as indicated in the "Value" column. (Where three values are given, the first one is usually valid for alpha and sparc, the middle one for i386, ppc and sh, and the last one for mips. A - denotes that a signal is absent on the corresponding architecture.)
The SIGUSR1 will have exactly one value on whatever machine you're running on ... there are no alternate values; just use the defined constant SIGUSR1. Using 16 will give you the wrong signal ... look further in the table and you will see SIGSTKFLT.
I need one more custom signal
What's wrong with SIGUSR2?
Upvotes: 6
Reputation: 6606
SIGUSR1 value is platform dependent.SIGUSR1 can be 30, 10, or 16. For example, x86-based Linux defines SIGUSR1 as 10. In fact, the only flavors of Linux that use 30 for SIGUSR1 are DEC Alpha and SPARC.
Upvotes: 2
Reputation: 59426
Signals are just numbers sent from one process to another. Only in rare situations like SIGKILL
the system interferes and handles them specially; the default is to send the signal number to the other process and let it handle this. To wrap that up and make it portable, there are conventions which number is used for which situation (and a list of #define
s supporting these conventions). Some of these conventions are generalized in the POSIX standard which the man 7 signal
is referring to.
You are totally free to use signals as you like (e. g. by using numbers without using any #define
s). Just be aware that by this you might lose portability and understandability. (The next developer maintaining your code might want to kill you for this.)
Upvotes: -1