wait for the specific pid.
Also check non-zero exit status.