From cee1695e0839d0672113e7445cec0722559585ee Mon Sep 17 00:00:00 2001 From: Dirk Gadsden Date: Sun, 31 Jan 2016 11:50:22 -0800 Subject: [PATCH] Safety docs about `std::process::Child` going out of scope There is no `Drop` implemented for `Child`, so if it goes out of scope in Rust-land and gets deallocated, the child process will continue to exist and execute. If users want a guarantee that the process has finished running and exited they must manually use `kill`, `wait`, or `wait_with_output`. Fixes #31289. --- src/libstd/process.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 7197dfa8b2d..2cfbef1e1b7 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -47,6 +47,14 @@ /// /// assert!(ecode.success()); /// ``` +/// +/// # Safety +/// +/// Take note that there is no implementation of +/// [`Drop`](../../core/ops/trait.Drop.html) for child processes, so if you +/// not ensure the `Child` has exited (through `kill`, `wait`, or +/// `wait_with_output`) then it will continue to run even after the `Child` +/// handle to it has gone out of scope. #[stable(feature = "process", since = "1.0.0")] pub struct Child { handle: imp::Process,