I have the following code in a bash script:
for job in `jobs -p`; do
echo "PID => ${job}"
if ! wait ${job} ; then
echo "At least one test failed with exit code => $?" ;
EXIT_CODE=1;
fi
done
wait <pid>
, in this case, wait ${job}
, should return the exit code, but I don't know how to get/see the value. What I need to do is change the above script to something like this:
for job in `jobs -p`; do
echo "PID => ${job}"
CODE=0;
wait ${job} || CODE=$?
if ! ${CODE} ; then
echo "At least one test failed with exit code => ${CODE}" ;
EXIT_CODE=1;
fi
done
is there a cleaner less verbose way to do this? I am confused about how to retrieve the "return value" from wait <pid>
, besides using the technique I just used. Is there another way to do it?