Quote:
Originally Posted by primerib
Here's a breakdown:
Code:
until [ "$DONE1" ] && [ "$DONE2" ]; do # loop until $DONE1 and $DONE2 exist (ie: until both processes return)
if [ check for process1 return ] && [ ! "$DONE1" ]; then # check if process1 has returned && if we should do this check
if [ process1 error ]; then do kill process2; exit 1; fi # process1 returned, did it have an error? if yes, kill process2 and exit script
DONE1=1 # process1 returned without error, set DONE1 flag to tell the script we don't need
# to check this anymore
elif [ check for process2 return ] && [ ! "$DONE2" ]; then # check ifprocess2 has returned && we should do this check
if [ process2 error ]; then do kill process1; exit 1; fi # process2 returned, did it have an error? if yes, kill process1 and exit script
DONE2=1 # process2 returned without error, set DONE2 flag to tell the script we don't need
# to check this anymore
fi
done # if DONE1 is set && DONE2 is set, both processes returned without error and we are finished with the check
So setting DONE1 and DONE2 to a value just says the process returned without error.
|
Wouldn't the first line be:
Code:
until [ "$DONE1" ] || [ "$DONE2" ]; do
If I use && and "wait for both processes to exit" then there would be no point in killing process2 if process1 exits with an error since both processes have already exited. I mean it would work to wait for both processes to exit, but I am trying to save some time by killing the other process if one exits with an error. The reason is because each process take about an hour to run, and if one process exits with an error it invalidates my test, so I don't want to wait for an hour when both processes have to just be ran again.