Trap Ctrl-C in script

#!/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

rb/trap-ctl-c.txt · Last modified: 17/08/2015 13:39 by andrew