Handling Signals in bash

From NovaOrdis Knowledge Base
Revision as of 19:24, 25 September 2019 by Ovidiu (talk | contribs) (→‎Overview)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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