Function unshare::reap_zombies[][src]

pub fn reap_zombies() -> ZombieIterator

Creates iterator over zombie processes

On each iteration it calls waitpid() and returns child pid and exit status if there is zombie process. The operation is non-blocking. The iterator is exhausted when there are no zombie process at the moment,

Alternatively see a more comprehensive child_events() function.

Example

So waiting for all processes to finish may look like this:

    while alive.len() > 0 {
        sigwait()
        for (pid, status) in zombies() {
            alive.remove(pid);
        }
    }

Important Notes

  • If you are using this function you can’t reliably use Child::wait any more.
  • If you got SIGCHLD you must exhaust this iterator until waiting for next signal, or you will have zombie processes around