Created
February 18, 2013 03:21
-
-
Save michaelhood/4974940 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
trap outdirty SIGINT SIGTERM | |
function out() { | |
echo "out, cleaning up" | |
} | |
function outgood() { | |
echo "success" | |
} | |
function outdirty() { | |
echo "got killed" | |
out | |
} | |
function outfail() { | |
echo "got fail: $@" | |
out | |
} | |
function j1() { | |
{ for i in {1..5}; do echo j1: $i; sleep 1; done && echo "stage j1"; } || outfail "j1 sad" $? | |
} | |
function j2() { | |
{ for i in {1..5}; do echo j2: $i; sleep 1; done && echo "stage j2"; } || outfail "j2 sad" $? | |
} | |
function j3() { | |
{ for i in {1..5}; do echo j3: $i; sleep 1; done && echo "stage j3"; } || outfail "j3 sad" $? | |
} | |
{ j1; } & | |
{ j2; } & | |
{ j3; } & | |
wait | |
outgood |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment