I have a live CD that boots into Linux and runs a small Bash script. The script searches for and runs a second program (which is usually a compiled C++ binary).
You're supposed to be able to abort the second program by pressing Ctrl+C. What should happen is that the second program halts, and the Bash script continues running cleanup. What actually happens is that both the main application and the Bash script terminate. Which is a problem.
So I used the trap
builtin to tell Bash to ignore SIGINT. And now Ctrl+C terminates the C++ application, but Bash continues its run. Great.
Oh yeah... Sometimes the "second application" is another Bash script. And in that case, Ctrl+C now does nothing whatsoever.
Clearly my understanding of how this stuff works is wrong... How do I control which process gets SIGINT when the user presses Ctrl+C? I want to direct this signal to just one specific process.