Capturing the exit status of the script running in background

Hi All,

I have a scenario where I am executing some child shell scripts in background (using &)through a master parent script.

Is there a way I can capture the exit status of each individual child script after the execution is completed.

With a regular, plain wait: no.
But you could use a construct like this (untested)

mkfifo /tmp/my_states
( /path/to/child_1 parameters; echo "child 1: $?" > /tmp/states ) &
( /path/to/child_2 parameters; echo "child 2: $?" > /tmp/states ) &
wait

That should give you the return codes via the FIFO.

Ok Thanks...

There is one more issue.

For some odd reason the master driver script is not returning to shell when I am executing the scripts in background. Not sure why :frowning:

So currently using Ctrl+C to exit.