From a6ef99e9f43e70c36dc9744bc87374033b2dedba Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 15 Sep 2017 22:57:12 -0400 Subject: [PATCH 1/4] Indicate how ChildStd{in,out,err} FDs are closed. Fixes https://github.com/rust-lang/rust/issues/41452. --- src/libstd/process.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index a3a7e91dd807d..4dba9a4cb1123 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -153,8 +153,12 @@ impl fmt::Debug for Child { /// /// This struct is used in the [`stdin`] field on [`Child`]. /// +/// When an instance of `ChildStdin` is [dropped], the `ChildStdin`'s underlying +/// file handle will be closed. +/// /// [`Child`]: struct.Child.html /// [`stdin`]: struct.Child.html#structfield.stdin +/// [dropped]: ../ops/trait.Drop.html #[stable(feature = "process", since = "1.0.0")] pub struct ChildStdin { inner: AnonPipe @@ -196,8 +200,12 @@ impl fmt::Debug for ChildStdin { /// /// This struct is used in the [`stdout`] field on [`Child`]. /// +/// When an instance of `ChildStdout` is [dropped], the `ChildStdout`'s +/// underlying file handle will be closed. +/// /// [`Child`]: struct.Child.html /// [`stdout`]: struct.Child.html#structfield.stdout +/// [dropped]: ../ops/trait.Drop.html #[stable(feature = "process", since = "1.0.0")] pub struct ChildStdout { inner: AnonPipe @@ -239,8 +247,12 @@ impl fmt::Debug for ChildStdout { /// /// This struct is used in the [`stderr`] field on [`Child`]. /// +/// When an instance of `ChildStderr` is [dropped], the `ChildStderr`'s +/// underlying file handle will be closed. +/// /// [`Child`]: struct.Child.html /// [`stderr`]: struct.Child.html#structfield.stderr +/// [dropped]: ../ops/trait.Drop.html #[stable(feature = "process", since = "1.0.0")] pub struct ChildStderr { inner: AnonPipe From a1f9052be76c7d28fe2ee1ff7dcb2464237c2bfc Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 15 Sep 2017 23:02:50 -0400 Subject: [PATCH 2/4] Expand some of the std{in,out,err} usages. --- src/libstd/process.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 4dba9a4cb1123..a70e632fe7cc4 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -106,15 +106,18 @@ use sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; pub struct Child { handle: imp::Process, - /// The handle for writing to the child's stdin, if it has been captured + /// The handle for writing to the child's standard input (stdin), if it has + /// been captured. #[stable(feature = "process", since = "1.0.0")] pub stdin: Option, - /// The handle for reading from the child's stdout, if it has been captured + /// The handle for reading from the child's standard output (stdout), if it + /// has been captured. #[stable(feature = "process", since = "1.0.0")] pub stdout: Option, - /// The handle for reading from the child's stderr, if it has been captured + /// The handle for reading from the child's standard error (stderr), if it + /// has been captured. #[stable(feature = "process", since = "1.0.0")] pub stderr: Option, } @@ -149,7 +152,7 @@ impl fmt::Debug for Child { } } -/// A handle to a child process's stdin. +/// A handle to a child process's standard input (stdin). /// /// This struct is used in the [`stdin`] field on [`Child`]. /// @@ -196,7 +199,7 @@ impl fmt::Debug for ChildStdin { } } -/// A handle to a child process's stdout. +/// A handle to a child process's standard output (stdout). /// /// This struct is used in the [`stdout`] field on [`Child`]. /// @@ -546,7 +549,8 @@ impl Command { self } - /// Configuration for the child process's stdin handle (file descriptor 0). + /// Configuration for the child process's standard input (stdin) handle + /// (file descriptor 0). /// /// # Examples /// @@ -566,7 +570,8 @@ impl Command { self } - /// Configuration for the child process's stdout handle (file descriptor 1). + /// Configuration for the child process's standard output (stdout) handle + /// (file descriptor 1). /// /// # Examples /// @@ -586,7 +591,8 @@ impl Command { self } - /// Configuration for the child process's stderr handle (file descriptor 2). + /// Configuration for the child process's standard error (stderr) handle + /// (file descriptor 2). /// /// # Examples /// From 5ee7db6a0ebe8803d420c591325605111a21a400 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Thu, 21 Sep 2017 21:01:51 -0400 Subject: [PATCH 3/4] Remove platform-specific terminology. --- src/libstd/process.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index a70e632fe7cc4..33451a470d013 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -549,8 +549,7 @@ impl Command { self } - /// Configuration for the child process's standard input (stdin) handle - /// (file descriptor 0). + /// Configuration for the child process's standard input (stdin) handle. /// /// # Examples /// @@ -570,8 +569,7 @@ impl Command { self } - /// Configuration for the child process's standard output (stdout) handle - /// (file descriptor 1). + /// Configuration for the child process's standard output (stdout) handle. /// /// # Examples /// @@ -591,8 +589,7 @@ impl Command { self } - /// Configuration for the child process's standard error (stderr) handle - /// (file descriptor 2). + /// Configuration for the child process's standard error (stderr) handle. /// /// # Examples /// From 859ebef62fa0e7fcfc2af200dac11d2f899ea37f Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Thu, 21 Sep 2017 21:11:11 -0400 Subject: [PATCH 4/4] Add note about being blocked on input. --- src/libstd/process.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 33451a470d013..1869ad3ed707a 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -157,7 +157,8 @@ impl fmt::Debug for Child { /// This struct is used in the [`stdin`] field on [`Child`]. /// /// When an instance of `ChildStdin` is [dropped], the `ChildStdin`'s underlying -/// file handle will be closed. +/// file handle will be closed. If the child process was blocked on input prior +/// to being dropped, it will become unblocked after dropping. /// /// [`Child`]: struct.Child.html /// [`stdin`]: struct.Child.html#structfield.stdin