Chapter 22: Signals — Advanced Features

 

Chapter 22: Signals — Advanced Features
Deep dive into Linux signal internals: core dumps, realtime signals, sigsuspend, signalfd and more
13
Topics
40+
Code Examples
60+
Interview Q&A
Free
Resource

What You Will Learn

This chapter continues from Chapter 20 and 21, covering advanced signal topics used every day in embedded Linux and systems programming. You will learn how processes dump core, how realtime signals differ from standard signals, how to safely wait for signals without race conditions, and how to receive signals through a file descriptor — all with real C code examples.

Key Concepts in This Chapter

Core Dump SIGKILL / SIGSTOP SIGCONT TASK_INTERRUPTIBLE TASK_UNINTERRUPTIBLE Hardware Signals Synchronous Signals Asynchronous Signals Realtime Signals sigqueue() sigsuspend() sigwaitinfo() signalfd() Race Condition Signal Mask

Chapter Contents

22.1 — Core Dump Files

Learn what a core dump is, when it is produced, when it is NOT produced, and how Linux lets you control the name and location of core dump files.

What is a Core Dump ulimit -c /proc/sys/kernel/core_pattern Conditions that suppress core dumps

Open Topic →

22.2 — Special Cases: Delivery, Disposition, and Handling

Special rules for SIGKILL, SIGSTOP, SIGCONT and the stop signals. These signals have unique kernel-level behaviour you must know.

SIGKILL / SIGSTOP SIGCONT behaviour Pending signal rules

Open Topic →

22.3 — Interruptible and Uninterruptible Sleep States

Understand how the Linux kernel puts processes to sleep and why SIGKILL cannot always act immediately.

TASK_INTERRUPTIBLE TASK_UNINTERRUPTIBLE TASK_KILLABLE ps STAT field

Open Topic →

22.4 — Hardware-Generated Signals

SIGBUS, SIGFPE, SIGILL, SIGSEGV — signals triggered by CPU exceptions. Learn why you cannot safely ignore or block them.

Hardware exceptions SIGFPE / SIGSEGV Infinite loop danger siglongjmp() escape

Open Topic →

22.5 — Synchronous and Asynchronous Signal Generation

Not all signals arrive unpredictably. Learn the difference between signals generated by external events vs signals you generate yourself.

Synchronous signals Asynchronous signals raise() / kill()

Open Topic →

22.6 — Timing and Order of Signal Delivery

When exactly is a pending signal delivered? What happens when multiple signals are unblocked at once?

Kernel-to-user mode switch Ascending signal order Nested handlers

Open Topic →

22.7 — Implementation and Portability of signal()

Why sigaction() is always preferred over signal(). Understand the historical differences between System V and BSD semantics.

Reliable vs unreliable signals SA_RESTART / SA_RESETHAND Implementing signal() with sigaction()

Open Topic →

22.8 — Realtime Signals

POSIX realtime signals: queued delivery, guaranteed order, data attachment via sigqueue(). This is critical for embedded and real-time systems.

SIGRTMIN / SIGRTMAX sigqueue() SA_SIGINFO handler siginfo_t structure

Open Topic →

22.9 — Waiting for a Signal Using a Mask: sigsuspend()

The classic race condition when unblocking and waiting for a signal — and how sigsuspend() solves it atomically.

Race condition with pause() sigsuspend() atomicity Critical section pattern

Open Topic →

22.10 — Synchronously Waiting for a Signal

Use sigwaitinfo() and sigtimedwait() to wait for signals without writing a signal handler at all.

sigwaitinfo() sigtimedwait() Timeout / poll mode

Open Topic →

22.11 — Fetching Signals via a File Descriptor

The Linux-specific signalfd() lets you read signals like reading a file — perfect for event-loop architectures with select/poll/epoll.

signalfd() signalfd_siginfo struct epoll integration SFD_NONBLOCK

Open Topic →

22.12 — Interprocess Communication with Signals

Can signals be used for IPC? Learn the limitations that make signals a poor general-purpose IPC mechanism.

Signal as IPC Bandwidth limitations Asynchronous complexity

Open Topic →

22.13 — Earlier Signal APIs (System V and BSD)

Legacy APIs: sigset(), sighold(), sigvec(), sigblock() — what they are and why you should use POSIX equivalents instead.

System V: sigset() sighold() BSD: sigvec() sigblock() POSIX equivalents

Open Topic →

Start Learning Now

All tutorials are free. Work through them in order for best understanding.

Begin with Core Dumps → Jump to Realtime Signals

Leave a Reply

Your email address will not be published. Required fields are marked *