Differences

This shows you the differences between two versions of the page.

Link to this comparison view

rb:trap-ctl-c [17/08/2015 14:39] (current)
andrew created
Line 1: Line 1:
 +====== Trap Ctrl-C in script ======
 +
 +<code bash>
 +#!/bin/bash
 +
 +#trapping Control + C
 +#these statements must be the first statements in the script to trap the CTRL C event
 +
 +trap ctrl_c INT
 +
 +function ctrl_c() ​ {
 +        logMsgToConfigSysLog "​INFO"​ "INFO: Aborting the script."​
 +        exit 1
 +}
 +
 +#Rest of script
 +
 +</​code>​
  

rb/trap-ctl-c.txt ยท Last modified: 17/08/2015 14:39 by andrew