pub async fn wait_all(
processes: &mut [&mut RunningProcess],
) -> Result<Vec<Option<i32>>>Expand description
Wait for all of several running processes to exit, returning their exit
codes (None for a signal-killed run) in the same order as processes.
The companion to wait_any: where wait_any races and returns the first
finisher, wait_all drives every contender to completion concurrently and
collects them. The processes are only borrowed and stay usable afterwards
(the exit status tokio caches remains re-readable). This is the natural
primitive for fanning a fixed set of children out and joining on the lot.
use processkit::{Command, ProcessGroup, wait_all};
let group = ProcessGroup::new()?;
let mut a = group.start(&Command::new("worker-a")).await?;
let mut b = group.start(&Command::new("worker-b")).await?;
let codes = wait_all(&mut [&mut a, &mut b]).await?;
assert_eq!(codes.len(), 2); // one entry per process, in input orderSame two non-features as wait_any: no per-process
timeout (bound the whole batch with
tokio::time::timeout) and no output pumping (a contender that fills
its stdout/stderr pipe blocks forever — drain chatty children first). Unlike
wait_any, an empty slice resolves immediately to an empty Vec: collecting
zero outcomes is well-defined, where racing none is not.
If a contender fails to reap (an OS I/O error), that Err is returned and
the remaining processes stay waitable (cancel-safe).