3

Can linux kernel receive signals for an application process while executing a signal handler of the same process? If yes, are both tasks multi-threaded? Or is it through some other way that I do not know?

6
  • ulimit -a shows me: pending signals (-i) 30745. That is a strong hint that there is a large queue used to store signals that will be passed to my user's processes in order, when my process is scheduled to receive them. Hardware can send CPU interrupts which the kernel can store within an ISR. Software signals are issued when the kernel is already in a system call. Nothing needs to multi-thread to make this work. Commented Jan 6, 2021 at 14:19
  • Signals are of two types: standard and real-time. Standard signals are not queued(these are maintained in a bitmask) while real-time signals are. What type of signal does the above output indicate? Moreover, how can we know that a signal handler can be interrupted by the delivery of another signal?
    – avrgamp
    Commented Jan 6, 2021 at 20:33
  • Thanks for your summary of the 40 pages about signals in the GNU Libc manual. However, this extract from 24.4.4 indicates that signals are queued: "When the handler for a particular signal is invoked, that signal is automatically blocked until the handler returns. That means that if two signals of the same kind arrive close together, the second one will be held until the first has been handled." Commented Jan 6, 2021 at 23:19
  • The answer to your main question is Yes. For some detail about signals you could read this. The answer to your follow-up question is it will be multi-threaded if your process is multi-threaded. The rules for signals in a multi-threaded process are defined by posix (try reading this) but the signal will be delivered to one of your existing threads. Commented Jan 7, 2021 at 2:40
  • @Paul_Pedant The next paragraph from the page you referred answers my question: "However, your handler can still be interrupted by delivery of another kind of signal. To avoid this, you can use the sa_mask member of the action structure passed to sigaction to explicitly specify which signals should be blocked while the signal handler runs. These signals are in addition to the signal for which the handler was invoked, and any other signals that are normally blocked by the process". I have been looking at my question from the the point of view of syscalls and not GNU libc.
    – avrgamp
    Commented Jan 7, 2021 at 7:55

0

You must log in to answer this question.

Browse other questions tagged .