Handling Signals in bash: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 14: | Line 14: | ||
trap '<''executable code or function name''>' <''signal''> | trap '<''executable code or function name''>' <''signal''> | ||
<syntaxhighlight lang='bash'> | |||
... | ... | ||
function sigint() { | function sigint() { | ||
Line 24: | Line 24: | ||
trap 'sigint' INT | trap 'sigint' INT | ||
... | ... | ||
</syntaxhighlight> |
Revision as of 20:04, 29 January 2018
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
...