I want to launch a background process from bash
in such a way that I can then send SIGINT signals to it (eg: via kill
or htop
). How do I do that?
By default, when a process is launched in the backround, SIGINT
and SIGQUIT
are ignored (see this question).
If the process is execed (=isn't just a subshell but is based on binary), you can run it through a wrapper that'll undo the SIGINT/SIGQUIT ignore:
reset_sigint.c:
To prevent the SIGINT/SIGQUIT ignore more generically for any process run as a command in the shell, you can run it with
set -m
onbut that'll run the command in a separate process group as a (possibly undesirable) sideffect.