Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly SIG_DFL do?

What exactly SIG_DFL (defaut handler for signals) does? I'm interested in debugging SIGTSTP. It misbehaves slightly under weird conditions. I have suspicion it is doing something strange if one the threads is in the TASK_ININTERRUPTBLE state.

Where is SIG_DFL source code? Libc?

Thanks.

like image 436
George Shuklin Avatar asked Nov 25 '15 16:11

George Shuklin


People also ask

What is Sig_dfl?

SIG_DFL specifies the default action for the particular signal. The default actions for various kinds of signals are stated in Standard Signals. SIG_IGN. SIG_IGN specifies that the signal should be ignored.

Should I use signal or Sigaction?

Portability Note: The basic signal function is a feature of ISO C, while sigaction is part of the POSIX. 1 standard. If you are concerned about portability to non-POSIX systems, then you should use the signal function instead.

How do you ignore a signal?

If you want to ignore the signal specified by the first argument (i.e., pretending that the signal never happens), use SIG_IGN for the second argument. In the above two lines, SIGINT and SIGALRM are ignored. If you want the system to use the default way to handle a signal, use SIG_DFL for the second argument.


1 Answers

What exactly SIG_DFL (defaut handler for signals) do?

It does exactly what one would expect: informs the kernel that there is no user signal handler for the given signal, and that the kernel should take default action for it (the action itself may be to ignore the signal, to terminate the program (with or without core dump), etc. depending on the signal).

Where is SIG_DFL source code? Libc?

There is usually a #define SIG_DLF -1 in /usr/include/signal.h, but the decision on what to do is in the kernel.

like image 182
Employed Russian Avatar answered Sep 27 '22 20:09

Employed Russian