In Bash, ignoring a signal is the process of instructing the shell to discard specific asynchronous POSIX signals (such asDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
SIGINT or SIGTERM) rather than executing their default disposition. This is achieved using the trap builtin command by binding an empty string ('' or "") as the command argument for the target signal.
Syntax
''(Empty String): The exact mechanism that instructs the shell to ignore the signal. Note that if the command argument is omitted but aSIGNAL_SPECis provided (e.g.,trap SIGINT), Bash resets the signal to its default disposition. To print the current signal handlers, all arguments must be omitted (i.e., invoking justtraportrap -p).SIGNAL_SPEC: The signal to be ignored. This can be the signal name with theSIGprefix (e.g.,SIGINT), the signal name without the prefix (e.g.,INT), or the numeric signal value (e.g.,2).
Implementation Examples
Technical Characteristics
- Unignorable Signals: The POSIX standard dictates that
SIGKILLandSIGSTOPcannot be caught, blocked, or ignored. Attempting to trap these in Bash will result in an error. - Inheritance of Ignored Signals on Entry: Per POSIX and Bash rules, signals that are already ignored upon entry to the shell environment cannot be trapped, caught, or reset to their default disposition by the script. Any attempt to change the disposition of a signal that was ignored at startup is silently discarded.
- Child Process Inheritance: When a signal is explicitly ignored in a Bash script using
trap '' SIGNAL, all child processes and subshells spawned by that script will inherit the ignored disposition. This is a distinct behavior compared to trapping a signal with an executable command, which Bash resets to the default disposition upon forking a child process. - Restoring Default Disposition: To stop ignoring a signal and revert it to its default operating system behavior, the
trapcommand is invoked with a dash (-) as the command argument, or by omitting the command argument entirely.
Master Bash with Deep Grasping Methodology!Learn More





