Bash Trap Control C

Do you want to catch control-c keyboard interrupts in your Bash program? Use the Bash builtin trap command to catch system signals. The following runs control_c() when a user interrupts the main() section with a Control-C (SIGINT).

#!/bin/bash
 
cleanup()
# example cleanup function
{
  rm -f /tmp/tempfile
  return $?
}
 
control_c()
# run if user hits control-c
{
  echo -en "\n*** Ouch! Exiting ***\n"
  cleanup
  exit $?
}
 
# trap keyboard interrupt (control-c)
trap control_c SIGINT
 
# main() loop
while true; do read x; done


Comments

necklaces. Omega watches

necklaces. Omega watches replica A collar may soften watch replica the shortening eff watches replica ect of New Replica Rolex a ball gown causes. Franck Muller Sunset Quartz replica watch Simple pearl collar wit exact Breitling replicas h relatively replica handbags Thomas Wylde Oxford Clutch Copper for sale complicated-look ball gown is replica knockoffs fake handbags a perfe best replica handbags ct match replica tiffany jewelry and will make you Tiffany key Chains jewelry look like a princess replica tiffany jewelry on your replica handbags biggest day. A designer replica handbags mermaid style of wedding Gucci Continental Wallet Beige 167464 sale dress is replica watches most likely not so Maurice Lacroix Calipso sale popular because it only replica watches s