Show pageBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== How to trap interrupts in the bash shell ====== <code bash> #!/bin/bash myCleanup() { rm -f /myapp/tmp/mylog return $? } myExit() { echo -en "\n*** Exiting ***\n" myCleanup exit $? } trap myExit SIGINT # main loop while true do echo -n "Enter your name: " read x echo "Hello $x" done </code> Ref: http://mariusvw.com/2010/05/18/how-to-trap-catch-keyboard-interrupt-in-bash-on-linux-freebsd/ {{tag>linux bash}} ~~LINKBACK~~ ~~DISCUSSION~~ blog/how_to_trap_interrupts_in_the_bash_shell.txt Last modified: 2011/02/16 20:15by brb