Skip to content

Commit b1a1861

Browse files
Rollup merge of #44625 - frewsxcv:frewsxcv-raii-stdin, r=QuietMisdreavus
Indicate how ChildStd{in,out,err} FDs are closed. Fixes #41452.
2 parents 8a25ec0 + 859ebef commit b1a1861

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

src/libstd/process.rs

+24-8
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,18 @@ use sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
106106
pub struct Child {
107107
handle: imp::Process,
108108

109-
/// The handle for writing to the child's stdin, if it has been captured
109+
/// The handle for writing to the child's standard input (stdin), if it has
110+
/// been captured.
110111
#[stable(feature = "process", since = "1.0.0")]
111112
pub stdin: Option<ChildStdin>,
112113

113-
/// The handle for reading from the child's stdout, if it has been captured
114+
/// The handle for reading from the child's standard output (stdout), if it
115+
/// has been captured.
114116
#[stable(feature = "process", since = "1.0.0")]
115117
pub stdout: Option<ChildStdout>,
116118

117-
/// The handle for reading from the child's stderr, if it has been captured
119+
/// The handle for reading from the child's standard error (stderr), if it
120+
/// has been captured.
118121
#[stable(feature = "process", since = "1.0.0")]
119122
pub stderr: Option<ChildStderr>,
120123
}
@@ -149,12 +152,17 @@ impl fmt::Debug for Child {
149152
}
150153
}
151154

152-
/// A handle to a child process's stdin.
155+
/// A handle to a child process's standard input (stdin).
153156
///
154157
/// This struct is used in the [`stdin`] field on [`Child`].
155158
///
159+
/// When an instance of `ChildStdin` is [dropped], the `ChildStdin`'s underlying
160+
/// file handle will be closed. If the child process was blocked on input prior
161+
/// to being dropped, it will become unblocked after dropping.
162+
///
156163
/// [`Child`]: struct.Child.html
157164
/// [`stdin`]: struct.Child.html#structfield.stdin
165+
/// [dropped]: ../ops/trait.Drop.html
158166
#[stable(feature = "process", since = "1.0.0")]
159167
pub struct ChildStdin {
160168
inner: AnonPipe
@@ -192,12 +200,16 @@ impl fmt::Debug for ChildStdin {
192200
}
193201
}
194202

195-
/// A handle to a child process's stdout.
203+
/// A handle to a child process's standard output (stdout).
196204
///
197205
/// This struct is used in the [`stdout`] field on [`Child`].
198206
///
207+
/// When an instance of `ChildStdout` is [dropped], the `ChildStdout`'s
208+
/// underlying file handle will be closed.
209+
///
199210
/// [`Child`]: struct.Child.html
200211
/// [`stdout`]: struct.Child.html#structfield.stdout
212+
/// [dropped]: ../ops/trait.Drop.html
201213
#[stable(feature = "process", since = "1.0.0")]
202214
pub struct ChildStdout {
203215
inner: AnonPipe
@@ -239,8 +251,12 @@ impl fmt::Debug for ChildStdout {
239251
///
240252
/// This struct is used in the [`stderr`] field on [`Child`].
241253
///
254+
/// When an instance of `ChildStderr` is [dropped], the `ChildStderr`'s
255+
/// underlying file handle will be closed.
256+
///
242257
/// [`Child`]: struct.Child.html
243258
/// [`stderr`]: struct.Child.html#structfield.stderr
259+
/// [dropped]: ../ops/trait.Drop.html
244260
#[stable(feature = "process", since = "1.0.0")]
245261
pub struct ChildStderr {
246262
inner: AnonPipe
@@ -534,7 +550,7 @@ impl Command {
534550
self
535551
}
536552

537-
/// Configuration for the child process's stdin handle (file descriptor 0).
553+
/// Configuration for the child process's standard input (stdin) handle.
538554
///
539555
/// # Examples
540556
///
@@ -554,7 +570,7 @@ impl Command {
554570
self
555571
}
556572

557-
/// Configuration for the child process's stdout handle (file descriptor 1).
573+
/// Configuration for the child process's standard output (stdout) handle.
558574
///
559575
/// # Examples
560576
///
@@ -574,7 +590,7 @@ impl Command {
574590
self
575591
}
576592

577-
/// Configuration for the child process's stderr handle (file descriptor 2).
593+
/// Configuration for the child process's standard error (stderr) handle.
578594
///
579595
/// # Examples
580596
///

0 commit comments

Comments
 (0)