Created
September 21, 2012 06:02
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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
Exactly what i needed thanks!