Handling Signals in bash: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 7: Line 7:
* [[bash#Subjects|bash]]
* [[bash#Subjects|bash]]
* [[Linux Signals]]
* [[Linux Signals]]
* [[trap]]


=Overview=
=Overview=

Revision as of 23:58, 8 August 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
 ...