|
How to capture the status of background process
Hi All
I am performing a parallel job by using the background concept.
Here is what I am doing.
SCRIPTA
1. Take in the argument list store it in an Array
2. Call to SCRIPTB in a while loop till the arguments in the array are present. The call is as follows
. ./SCRIPTB [i] &
3. Use the wait command to wait for all the wait till all the background process are completed.
4. ECHO SUCCESS.
Now the point is that What I need to do is to perform some operation if all the call to SCRIPTB were succesful. Now for this I am doing the following
1. Take in the argument list store it in an Array
2. Call to SCRIPTB in a while loop till the arguments in the array are present. The call is as follows
. ./SCRIPTB [i] &
if [ $? -eq 0 ] #ok execution
then
echo Incrementing the counter for ${brn_array[brnIndex]}
successCounter=`expr $successCounter + 1`
fi
3. Use the wait command to wait for all the wait till all the background process are completed.
4. Verify the counter and print SUCCESS
But the problem is that even if for some arguments . ./SCRIPTB [i] fails then also the return value is 0 and the counter is increasing.
Kindly suggest
|