I know how to get exit code from last called program. But how can I check exit codes in the following scenario
prog1 &
prog2 &
while [ true ]; do # main loop
while [ condition1 ]; do
prog1 <input >output
done
while [ condition2 ]; do
prog2 <input >output
done
done
my goal is to break the main loop and clean up processes after program 1 or 2 exits (with code =0 or !=0).
For instance:
Program 1 exits with code 0. Then I want to kill program2 and exit my script.
Program 2 exits with code 333. Then I want to kill program1 and exit script with code 222.