Created
March 24, 2018 05:27
-
-
Save ORESoftware/2f0444cadef5b3546fca0eec749b4b70 to your computer and use it in GitHub Desktop.
job control
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 wait_for_subshells_to_exit() { | |
set -m; # allow for job control | |
for job in `jobs -p`; do | |
process_info="$(ps -o comm | grep ${job})" | |
code=0; | |
wait ${job} || code=$? | |
if [[ "${code}" != "0" ]]; then | |
echo "A job (subshell) failed with exit code => ${code}" ; | |
echo "$process_info"; | |
exit 1; | |
fi | |
done | |
} | |
false & | |
wait_for_subshells_to_exit | |
echo "lol" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment