Skip to content

Instantly share code, notes, and snippets.

@vaughnd
Created September 21, 2012 06:02
Show Gist options
  • Save vaughnd/3759951 to your computer and use it in GitHub Desktop.
Save vaughnd/3759951 to your computer and use it in GitHub Desktop.
Bash script to run more than one process in parallel and kill all when exiting the script (via ctrl-c or kill)
#!/bin/bash
# kill all subshells and processes on exit
trap "kill 0" SIGINT
# start commands in subshells so all their spawn DIE when we exit
( process1 ) &
( process2 ) &
wait
@storenth
Copy link

Do we need set -m on the top of the script in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment