Skip to content

Commit 5ab00fd

Browse files
committed
Rollup merge of #31327 - dirk:dirk/process-child-safety-docs, r=alexcrichton
`Drop` is not 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. r? @steveklabnik
2 parents 22000d1 + 7683922 commit 5ab00fd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libstd/process.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ use thread::{self, JoinHandle};
4747
///
4848
/// assert!(ecode.success());
4949
/// ```
50+
///
51+
/// # Note
52+
///
53+
/// Take note that there is no implementation of
54+
/// [`Drop`](../../core/ops/trait.Drop.html) for child processes, so if you
55+
/// do not ensure the `Child` has exited then it will continue to run, even
56+
/// after the `Child` handle to the child process has gone out of scope.
57+
///
58+
/// Calling `wait` (or other functions that wrap around it) will make the
59+
/// parent process wait until the child has actually exited before continuing.
5060
#[stable(feature = "process", since = "1.0.0")]
5161
pub struct Child {
5262
handle: imp::Process,

0 commit comments

Comments
 (0)