If I just run sleep 1 & in bash, the sleep process will get reaped almost instantly after it dies. This happens whether job control is enabled or disabled. Is there a way I can make bash hold off on reaping the process until I do something like wait or fg? E.g.:
sleep 1 & sleep 2 ps -ef | grep defunct # I want this to show the sleep 1 process wait ps -ef | grep defunct # But now it should be gone
sleep 1? Isn't it normal that it will be gone after one second?wait()to fetch the exit status of the child. Before that happens, the dead process is still lying around in the process list as a so-called zombie process. You usually don't see them, since most programs that fork children just clean them up immediately.