Artificial intelligent assistant

zombie process reap without "wait" 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?

This is one of the pitfalls with having a shell mimic the OS API. It does create confusion. In this case you are confusing wait() (linux API) with wait (bash function).

Simply enough, Bash takes care of reaping processes for you, you don't generally need to think about this. The `wait` bash command has no effect on reaping processes.

When your child job terminates, bash will be informed via a SIGCHLD signal. This will when that happens bash will stop whatever it was doing for a moment and reap the stopped child. It then goes back to whatever it was doing.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy c27e04ed7f1d7792997ca0616b7364ca