Skip to content

Commit

Permalink
std::process:Child: discuss other problems with just dropping
Browse files Browse the repository at this point in the history
See rust-lang#70186 which makes the point about io handles.

Signed-off-by: Ian Jackson <[email protected]>
  • Loading branch information
ijackson committed Jan 28, 2021
1 parent a4ffa2c commit 0076a3b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,25 @@ use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
///
/// # Warning
///
/// A `Child` which is simply dropped may continue running in parallel,
/// possibly even after the program which launched it exits.
/// If it inherited stdin/stdout, it may still read and write to them
/// later, causing confusion and disruption.
///
/// On some systems, calling [`wait`] or similar is necessary for the OS to
/// release resources. A process that terminated but has not been waited on is
/// still around as a "zombie". Leaving too many zombies around may exhaust
/// global resources (for example process IDs).
///
/// Unless [`wait`] is called, any failure of the child will not be
/// visible.
///
/// The standard library does *not* automatically wait on child processes (not
/// even if the `Child` is dropped), it is up to the application developer to do
/// so. As a consequence, dropping `Child` handles without waiting on them first
/// is not recommended in long-running applications.
/// so.
///
/// For these reasons, dropping `Child` handles without waiting on them first
/// is usually incorrect.
///
/// # Examples
///
Expand Down

0 comments on commit 0076a3b

Please sign in to comment.