Checking Status of PID

I'm developing a script that spawns many background processes that will be executing concurrently and need to check the exit status of each spawned process after it terminates. After starting the background process I can get the pid from $! which I can store in an associative array but how do I check on the status and exit status of the pid? I suppose I should ask if this is even possible?

Thanks,
twk

I know it can be sort of done in ksh. After the wait for all process, the shell-builtin "jobs -nl" will list all stopped or exited jobs and the exit codes. See man ksh. You could e.g. use watchdog subprocesses with a timeout to kill off subprocesses that take too long.

cmd1 & id1=$!
cmd2 & id2=$!

wait "$id1"; status1=$!
wait "$id2"; status2=$!