1

I'm running shell scripts in parallel like below. Both scripts return code is ZERO but one of them is actually returning 2. Any idea what could be the issue. Based on return code i decide whether its success/fail

./shellscript1.sh & pid1=$!
ReturnCode=$?

./shellscript2.sh & pid2=$!
checkFlagReturnCode=$?


wait $pid1
wait $pid2
0

2 Answers 2

1

You cannot capture the return code of a background process which has not finished. You can get the return codes from wait not from $?.

Sign up to request clarification or add additional context in comments.

1 Comment

can you please elaborate more on how to get the return codes from wait
1

You can look to GNU Parallel. Their tutorial has lots of examples.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.