"When do bash
signal handlers NOT work?"
March 19th, 2019
Just in case somebody else runs into this frustrating situation, (at least on RHEL 7) bash
shell scripts trying to catch SIGINT
do not work when the signal is sent to the process from another pid and your bash script is running a non-shell built-in.
Yesterday I was attempting to mock out a linux command to verify the behavior of a shell script I wrote. The goal was to be able to test the shell script's behavior without actually invoking the particular linux command (see pbench PR #1108). One feature of the script being tested was sending a SIGINT
to another process, being sure the script had properly identified the correct process.
There is a nice blog about how to write signal handlers for bash, well worth the read [1]. Using that blog, I came up with a very simple mock command shell script: