Processes can ignore, block, or catch all signals except SIGSTOP and SIGKILL.
- Catch: If a process catches a signal, it means that it contains code that will take appropriate action when the signal is received.
- signal mask: Attribute of a thread. All the signals in signal mask are being blocked by the thread. To change it, use pthread_sigmask().
- If a masked signal occurs, it becomes pending (can be checked by sigpending (*set)), but doesn’t affect the execution of the process.
- When a pending signal is unmasked, it’s act upon immediately, before pthread_sigmask() returns.
- The signal actions (ignore, catch) are maintained at the process level.
- If a thread ignores or catches a signal, it affects all threads within that process.
- The signal mask(block, unblock) is maintained at the thread level.
- If a thread blocks a signal, it affects only that thread.
- An unignored signal targeted at a thread will be delivered to that thread alone.
- An unignored signal targeted at a process is delivered to the first thread that doesn’t have the signal blocked.
- If all threads have the signal blocked, the signal will be queued on the process until one thread ignores or unblocks it.
- A practical way is to mask the signals in all threads but one, which is dedicated to handling them.
- CTRL-C: SIGINT (signo 2)
- CTRL-Z: SIGTSTP (signo 24)
- Slay: SIGTERM (signo 15)
- Bad pointer/invalid memory address: SIGSEGV (signo 11)
- Hardware generates a fault – the kerneal set SIGSEGV signal on the process
- note: in QNX, SIGSEGV, is generated by the program itself, will target only the thread which causes the issue, not the process. the signal is not caught by the separate signal thread!
- SIGBUS (signo 10)
Send a signal to a process: slay -s <process name>
QNX extends the signal-delivery mechanisms of POSIX by allowing signals to be targeted at specific threads, rather than simply at the process containing the threads. QNX kernel uses common code to manage signal and pulse (8 bit code, 32-bit value). Signal number is mapped to a pulse priority using _SIGMAX-signo. As a result, signals are delivered in priority order with lower signal numbers having higher priority.