I have a Linux application, written in C++, which traps the SIGINT interrupt in order to do some final cleanup before exiting. I call this application within a bash script. Now, when I type control-C with the bash script running in the foreground, the script terminates as does the program it invoked but without running the final cleanup code. How can I have the interrupt pass through the bash script, directly to the application, resulting in the final cleanup and then a normal exit which then causes the script itself to exit?
bash also has the ability to trap SIGINT. It would be feasible to trap the signal so the script doesn't die, and then in the trap handler, use
kill to pass the signal off to your application.