Skip to content

Commit 0076a3b

Browse files
committed
std::process:Child: discuss other problems with just dropping
See #70186 which makes the point about io handles. Signed-off-by: Ian Jackson <[email protected]>
1 parent a4ffa2c commit 0076a3b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

library/std/src/process.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,25 @@ use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
132132
///
133133
/// # Warning
134134
///
135+
/// A `Child` which is simply dropped may continue running in parallel,
136+
/// possibly even after the program which launched it exits.
137+
/// If it inherited stdin/stdout, it may still read and write to them
138+
/// later, causing confusion and disruption.
139+
///
135140
/// On some systems, calling [`wait`] or similar is necessary for the OS to
136141
/// release resources. A process that terminated but has not been waited on is
137142
/// still around as a "zombie". Leaving too many zombies around may exhaust
138143
/// global resources (for example process IDs).
139144
///
145+
/// Unless [`wait`] is called, any failure of the child will not be
146+
/// visible.
147+
///
140148
/// The standard library does *not* automatically wait on child processes (not
141149
/// even if the `Child` is dropped), it is up to the application developer to do
142-
/// so. As a consequence, dropping `Child` handles without waiting on them first
143-
/// is not recommended in long-running applications.
150+
/// so.
151+
///
152+
/// For these reasons, dropping `Child` handles without waiting on them first
153+
/// is usually incorrect.
144154
///
145155
/// # Examples
146156
///

0 commit comments

Comments
 (0)