Function unshare::child_events [−][src]
pub fn child_events() -> ChildEventsIterator
Creates iterator over child events
On each iteration it calls waitpid()
and returns one of the
events described in ChildEvent
.
The operation is non-blocking. The iterator is exhausted when there are no zombie process at the moment.
Alternatively see a simpler reap_zombies()
function.
Example
So waiting for all processes to finish may look like this:
ⓘ
while alive.len() > 0 { sigwait() for event in zombies() { match event { Death(pid, _) => alive.remove(pid), Stop(..) => {} Continue(..) => {} } }
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