Created
February 18, 2016 23:59
-
-
Save smdern/359f76af6ad0a0878da8 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 | |
function check_status_code { | |
local name=$1 | |
local status=$2 | |
if [ $status -ne 0 ]; then | |
echo $name failed with status code $status | |
exit $status | |
fi | |
echo Success: $name with code $status | |
} | |
(sleep 8 ; echo "slow") & | |
slow=$! | |
(sleep 5 ; echo "med"; exit 1; echo "more stuff") & | |
med=$! | |
(sleep 2 ; echo "fast") & | |
fast=$! | |
wait $med | |
med_status=$? | |
wait $fast | |
fast_status=$? | |
wait $slow | |
slow_status=$? | |
check_status_code Fast $fast_status | |
check_status_code Med $med_status | |
check_status_code Slow $slow_status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment