How to send a signal SIGINT from script to script?
I was able to reproduce the behavior you report. My hypothesis is that since the script is running from a non-interactive shell (as a child of a script) that SIGINT
, which is a keyboard signal, is ignored.
From info bash
:
Background processes are those whose process group ID differs from the terminal's; such processes are immune to keyboard-generated signals.
I have found that if you trap
and kill
using another signal such as SIGUSR1
it works.
Additional information from man bash
:
Non-builtin commands run by bash have signal handlers set to the values inherited by the shell from its parent. When job control is not in effect, asynchronous commands ignore SIGINT and SIGQUIT in addition to these inherited handlers.
and
If bash is waiting for a command to complete and receives a signal for which a trap has been set, the trap will not be executed until the command completes.
and
Any trap on SIGCHLD is executed for each child that exits.