7aab3d38a0
std: Add a nonblocking `Child::try_wait` method This commit adds a new method to the `Child` type in the `std::process` module called `try_wait`. This method is the same as `wait` except that it will not block the calling thread and instead only attempt to collect the exit status. On Unix this means that we call `waitpid` with the `WNOHANG` flag and on Windows it just means that we pass a 0 timeout to `WaitForSingleObject`. Currently it's possible to build this method out of tree, but it's unfortunately tricky to do so. Specifically on Unix you essentially lose ownership of the pid for the process once a call to `waitpid` has succeeded. Although `Child` tracks this state internally to be resilient to multiple calls to `wait` or a `kill` after a successful wait, if the child is waited on externally then the state inside of `Child` is not updated. This means that external implementations of this method must be extra careful to essentially not use a `Child`'s methods after a call to `waitpid` has succeeded (even in a nonblocking fashion). By adding this functionality to the standard library it should help canonicalize these external implementations and ensure they can continue to robustly reuse the `Child` type from the standard library without worrying about pid ownership. |
||
---|---|---|
.. | ||
collections | ||
ffi | ||
io | ||
net | ||
os | ||
prelude | ||
rand | ||
sync | ||
sys | ||
sys_common | ||
thread | ||
time | ||
ascii.rs | ||
build.rs | ||
Cargo.toml | ||
env.rs | ||
error.rs | ||
f32.rs | ||
f64.rs | ||
fs.rs | ||
lib.rs | ||
macros.rs | ||
memchr.rs | ||
num.rs | ||
panic.rs | ||
panicking.rs | ||
path.rs | ||
primitive_docs.rs | ||
process.rs | ||
rt.rs | ||
rtdeps.rs |