User Tools

Site Tools


linux:trap-ctl-c

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
linux/trap-ctl-c.txt · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki