Handling Signals in bash: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
(One intermediate revision by the same user not shown)
Line 7: Line 7:
* [[bash#Subjects|bash]]
* [[bash#Subjects|bash]]
* [[Linux Signals]]
* [[Linux Signals]]
* [[trap]]


=Overview=
=Overview=
Line 25: Line 26:
  ...
  ...
</syntaxhighlight>
</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:

trap