Commit 5051671c authored by Tom Lanyon's avatar Tom Lanyon Committed by Ian Lance Taylor

os/exec: update docs for cmd.Std{out,err} and cmd.Wait to clarify how copying is done

Fixes #22610.

Change-Id: I172fe1d1941a8a2750af7ee75f7af7e81a702c40
Reviewed-on: https://go-review.googlesource.com/76320Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent ecc86503
...@@ -92,8 +92,17 @@ type Cmd struct { ...@@ -92,8 +92,17 @@ type Cmd struct {
// If either is nil, Run connects the corresponding file descriptor // If either is nil, Run connects the corresponding file descriptor
// to the null device (os.DevNull). // to the null device (os.DevNull).
// //
// If Stdout and Stderr are the same writer, and have a type that can be compared with ==, // If either is an *os.File, the process's standard output or standard
// at most one goroutine at a time will call Write. // error, respectively, are connected directly to that file. Otherwise,
// if either is not nil, during the execution of the command a separate
// goroutine reads from the process's standard output or standard error
// and delivers that to Stdout or Stderr. In this case, Wait does not
// complete until the goroutine stops copying, either because it has
// reached the end of Stdin (EOF or a read error) or because writing to
// the pipe returned an error.
//
// If Stdout and Stderr are the same writer, and have a type that can
// be compared with ==, at most one goroutine at a time will call Write.
Stdout io.Writer Stdout io.Writer
Stderr io.Writer Stderr io.Writer
...@@ -190,7 +199,7 @@ func (c *Cmd) argv() []string { ...@@ -190,7 +199,7 @@ func (c *Cmd) argv() []string {
} }
// skipStdinCopyError optionally specifies a function which reports // skipStdinCopyError optionally specifies a function which reports
// whether the provided the stdin copy error should be ignored. // whether the provided stdin copy error should be ignored.
// It is non-nil everywhere but Plan 9, which lacks EPIPE. See exec_posix.go. // It is non-nil everywhere but Plan 9, which lacks EPIPE. See exec_posix.go.
var skipStdinCopyError func(error) bool var skipStdinCopyError func(error) bool
...@@ -429,9 +438,8 @@ func (e *ExitError) Error() string { ...@@ -429,9 +438,8 @@ func (e *ExitError) Error() string {
// error is of type *ExitError. Other error types may be // error is of type *ExitError. Other error types may be
// returned for I/O problems. // returned for I/O problems.
// //
// If c.Stdin is not an *os.File, Wait also waits for the I/O loop // If any of c.Stdin, c.Stdout or c.Stderr are not an *os.File, Wait also waits
// copying from c.Stdin into the process's standard input // for the respective I/O loop copying to or from the process to complete.
// to complete.
// //
// Wait releases any resources associated with the Cmd. // Wait releases any resources associated with the Cmd.
func (c *Cmd) Wait() error { func (c *Cmd) Wait() error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment