Sample Header Ad - 728x90

Is it possible to defer reaping of background processes in bash?

0 votes
1 answer
178 views
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
Asked by Joseph Sible-Reinstate Monica (4220 rep)
Apr 19, 2023, 01:06 AM
Last activity: Apr 19, 2023, 09:17 AM