How to trap or catch Keyboard Interrupt in Bash

Sometimes you want to clean up some things when your script gets stopped for whatever reason.

This script captures the SIGINT signal and sends it to the myExit function.

The myExit function calls another function (just to show what is possible) which removes a logfile.

If you map the SIGINT signal to a function which would do nothing, keep in mind, you might get stuck 😉