How to trap interrupts in the bash shell

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

Ref: http://mariusvw.com/2010/05/18/how-to-trap-catch-keyboard-interrupt-in-bash-on-linux-freebsd/

~~LINKBACK~~

Enter your comment. Wiki syntax is allowed:
If you can't read the letters on the image, download this .wav file to get them read to you.