I like that the first is better for my purpose, I believe that "do something here if the process failed." I can kill the script that called this shell script for foo using this name.
I think the first solution works well for several children. Anyway, I needed to do this quickly, so I used a hack that works for my application:
I run the process in the background, as usual, basically a script, and then use $! to get its pid (since $! returns the last bg pid), sleep for 2 seconds and do ps -e | grep pid to check if the whole process is based on the return value (ps -e | grep pid). This works well for me, because if my background process is interrupted, it does it immediately (because the address is being used).
source share