C - what is syntactically SIGUSR1

When I use SIGUSR1 in the kill () or signal () functions, what does it do? Is this a macro? I read that it is user defined, but where is it defined? Can I make SIGUSR10 (or programmatically create an "array" of different types of signals)?

+6
source share
2 answers

User-defined signals mean that these signals do not have a specific meaning, unlike SIGSEGV , SIGCONT , SIGSTOP , etc. The kernel will never send SIGUSR1 or SIGUSR2 to the process, so the signal value can be set to you according to the needs of your application. All these uppercase SIG constants are actually macros that will expand to an integer indicating the signal number in a particular implementation. Although user-defined signals do not need to be defined, signal numbers are already fixed in a particular implementation and can be safely reassigned since they will not be sent by anything other than the user.

Traditionally, there are two user signals: SIGUSR1 and SIGUSR2 . However, in recent implementations there is something called "POSIX real-time signals" that offer some more custom signals.

+11
source

SIGUSR, as the name implies, means a signal reserved for use by the user (developer) without any β€œspecial” predetermined value. You cannot do 10 of them, on most POSIX systems there are exactly two - SIGUSR1 and SIGUSR2.

The character itself may or may not be macro expansion, but it will ultimately assign a numerical value compatible with int.

To use it in a meaningful way, you will need to write a signal handler. For more information on how to do this, see the signal () man page.

+3
source

Source: https://habr.com/ru/post/975009/


All Articles