I know if a subprocess does not get reaped properly, it will become a zombie and you can see it by ps
command.
Also the "wait [pid]" command will wait for subshell running on the background until it finishes and reap it.
I have a script like this:
#!/bin/bash
sleep 5 &
tail -f /dev/null
My question is, I don't use wait
after sleep 5 &
and the parent shell will never terminate because of tail
, then why the sleep 5 &
will not become a zombie? I see it disappear after finishing in ps
, not sure who reaps it?