trap-event

INT

Handle SIGINT when catchable. A handler can explicitly exit with a conventional status; self-signal example does not model terminal process groups.

Formal Syntax & Structure

bash syntaxbash
trap action INT

Return Value

signal

Handle SIGINT when catchable. A handler can explicitly exit with a conventional status; self-signal example does not model terminal process groups.

Working Example

Example Snippetbash
bash -c '    on_int() { printf "INT\n"; exit 130; }    trap on_int INT    kill -INT "$$"    printf "unreachable\n"'printf 'child=%s\n' "$?"
Bash Reference