How to propagate a signal to child processes from a Bash script - LinuxConfig.org

Suppose we write a script which spawns one or more long running processes; if said script receives a signal such as SIGINT or SIGTERM, we probably want its children to be terminated too (normally when the parent dies, the children survives). We may also want to perform some cleanup tasks before the script itself exits. To be able to reach our goal, we must first learn about process groups and how to execute a process in background.

This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-propagate-a-signal-to-child-processes-from-a-bash-script