I need to call a Java program in parallel threads from a unix shell script and wait for all the threads to complete. Then the return status (either 1 or 0) of each thread should be captured. if all the parallel threads are sucecssful, unix script will return SUCCESS else if at least one of the threads has errroed, then return FAIL. I found this code snippet on google which is very relevant to what I was looking for.
for count in {1..10}
do
call_process $count $runid &
JPID="$JPID $!"
done
for pid in $JPID; do
wait $pid || let 'RESULT+=1'
echo "RESULT - $RESULT"
done
function call_process {
java -Djava.security.egd=file:/dev/urandom -Xmx8192M -Dfile.encoding=ISO-8859-1 com.load.MainProg $1 $2
}
But here the result of the Java process is not captured. Is it possible to capture the java return status as well for each process id?