Handling Signals in bash: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
* [[bash#Subjects|bash]] | * [[bash#Subjects|bash]] | ||
* [[Linux Signals]] | |||
* [[trap]] | |||
=Overview= | =Overview= | ||
Line 13: | Line 15: | ||
trap '<''executable code or function name''>' <''signal''> | trap '<''executable code or function name''>' <''signal''> | ||
<syntaxhighlight lang='bash'> | |||
... | ... | ||
function sigint() { | function sigint() { | ||
Line 23: | Line 25: | ||
trap 'sigint' INT | trap 'sigint' INT | ||
... | ... | ||
</syntaxhighlight> | |||
For more details on how trap should be used, see: {{Internal|Trap|trap}} |
Latest revision as of 19:24, 25 September 2019
External
Internal
Overview
The signals are caught with the trap built-in.
trap '<executable code or function name>' <signal>
...
function sigint() {
echo "signal INT received"
exit 0
}
trap 'sigint' INT
...
For more details on how trap should be used, see: