Signals and Signal Handling
Explore how signals facilitate event notification between processes in C. Learn to register signal handlers, send signals using kill(), and understand the differences between signals and data-passing IPC methods for effective process communication.
We'll cover the following...
So far, we have examined IPC mechanisms that transfer data between processes: pipes stream bytes, shared memory maps regions, and message queues deliver structured messages. However, not all communication involves transferring data. Sometimes a process simply needs to notify another process that an event has occurred.
Signals provide this capability. A signal is a lightweight notification sent to a process by the operating system or by another process. Unlike pipes or message queues, signals do not carry structured data. Instead, they indicate that a particular event has occurred.
What is a signal?
A signal is an asynchronous notification delivered to a process. It interrupts the normal flow of execution and triggers a predefined action. By default, each signal has a predefined behavior. For example, SIGINT terminates a program. However, a ...