Handling Signals in bash: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 14: Line 14:




...
  function sigint() {
  function sigint() {
   
   
Line 19: Line 20:
   exit 0   
   exit 0   
  }
  }
 
  trap 'sigint' INT
  trap 'sigint' INT
...

Revision as of 19:43, 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
...