Unix - Signal Handling in UNIX and Common Signalsi
A signal in UNIX is a software interrupt sent to a process to notify it of an event. Signals provide a basic form of inter-process communication and are used to control process execution.
Signals can be generated by the kernel, another process, or the user. For example, pressing Ctrl+C sends the SIGINT signal to terminate a running process. Signals are identified by names and numbers.
When a process receives a signal, it can either handle, ignore, or block it. Handling means executing a predefined function. Some signals, like SIGKILL, cannot be caught or ignored and immediately terminate the process.
Common signals include SIGTERM for graceful termination, SIGKILL for forceful termination, SIGSTOP for stopping a process, and SIGCONT for resuming a stopped process. These signals help manage process lifecycle.
Signal handling is essential for clean program termination. Applications use SIGTERM to save data and release resources before exiting. Improper signal handling can cause data corruption or resource leaks.
Internally, the kernel maintains a signal table for each process. When a signal is delivered, the kernel checks the process’s signal handling configuration and acts accordingly.
Signal handling is fundamental in UNIX system programming, job control, and server management, enabling controlled and predictable process behavior.