Proper job control in Bash scripts
Simple example of how to properly launch background jobs and then gracefully terminate them.
- We could trap only the
EXITsignal, but then after killing workers we get an unwanted "Terminated" message.
- In worker scripts, we must call
exitwhen cleaning, to break out of the infinite loop
- After killing a worker, we still have to wait for them to gracefully terminate.