Skip to content

Commit 26199a2

Browse files
committed
doc: Warn about possible zombie apocalypse
Extend the std::process::Child docs with warning about possible zombies. The previous version mentioned that when dropping the Child, the process is not killed. However, the wording gave the impression that such behaviour is fine to do (leaving the reader believe low-level details like reaping zombies of the dead processes is taken over by std somehow; or simply leaving the reader unaware about the problem).
1 parent 47e0803 commit 26199a2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: src/libstd/process.rs

+12
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,18 @@ use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
134134
/// the parent process wait until the child has actually exited before
135135
/// continuing.
136136
///
137+
/// # Warning
138+
///
139+
/// On some system, calling [`wait`] or similar is necessary for the OS to
140+
/// release resources. A process that terminated but has not been waited on is
141+
/// still around as a "zombie". Leaving too many zombies around may exhaust
142+
/// global resources (for example process IDs).
143+
///
144+
/// The standard library does *not* automatically wait on child processes (not
145+
/// even if the `Child` is dropped), it is up to the application developer to do
146+
/// so. As a consequence, dropping `Child` handles without waiting on them first
147+
/// is not recommended in long-running applications.
148+
///
137149
/// # Examples
138150
///
139151
/// ```should_panic

0 commit comments

Comments
 (0)