1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Process management utilities
pub(crate) type ProcessId = i32;
/// Provides access to a child process.
pub struct Child {
inner: std::process::Child,
}
pub(crate) use std::process::{ExitStatus, Output};
impl Child {
/// Returns the process ID of the child process, if available.
pub fn id(&self) -> Option<u32> {
None
}
/// Asynchronously waits for the child process to exit.
///
/// # Errors
///
/// Returns the I/O error from waiting on the child process.
pub async fn wait(&mut self) -> std::io::Result<ExitStatus> {
self.inner.wait()
}
/// Asynchronously waits for the child process to exit and collects its
/// output.
///
/// # Errors
///
/// Returns the I/O error from waiting on the child process or collecting
/// its output.
pub async fn wait_with_output(self) -> std::io::Result<Output> {
self.inner.wait_with_output()
}
}
pub(crate) fn spawn(
mut command: std::process::Command,
kill_on_drop: bool,
) -> std::io::Result<Child> {
// No kill-on-drop on this stub platform; accepted and ignored.
let _ = kill_on_drop;
let child = command.spawn()?;
Ok(Child { inner: child })
}