From ccacab641af54f51bdca228445f464efde47e935 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Tue, 21 Feb 2012 14:10:34 +1100 Subject: os: replace non-portable Waitmsg with portable ProcessState Use methods for key questions. Provide access to non-portable pieces through portable methods. Windows and Plan 9 updated. R=golang-dev, bradfitz, bradfitz, r, dsymonds, rsc, iant, iant CC=golang-dev https://golang.org/cl/5673077 --- src/pkg/os/exec/exec.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/pkg/os/exec/exec.go') diff --git a/src/pkg/os/exec/exec.go b/src/pkg/os/exec/exec.go index 248d97d458..ebe92a9fba 100644 --- a/src/pkg/os/exec/exec.go +++ b/src/pkg/os/exec/exec.go @@ -79,9 +79,9 @@ type Cmd struct { // Process is the underlying process, once started. Process *os.Process - // Waitmsg contains information about an exited process, + // ProcessState contains information about an exited process, // available after a call to Wait or Run. - Waitmsg *os.Waitmsg + ProcessState *os.ProcessState err error // last error (from LookPath, stdin, stdout, stderr) finished bool // when Wait was called @@ -266,11 +266,11 @@ func (c *Cmd) Start() error { // An ExitError reports an unsuccessful exit by a command. type ExitError struct { - *os.Waitmsg + *os.ProcessState } func (e *ExitError) Error() string { - return e.Waitmsg.String() + return e.ProcessState.String() } // Wait waits for the command to exit. @@ -291,8 +291,8 @@ func (c *Cmd) Wait() error { return errors.New("exec: Wait was already called") } c.finished = true - msg, err := c.Process.Wait() - c.Waitmsg = msg + state, err := c.Process.Wait() + c.ProcessState = state var copyError error for _ = range c.goroutine { @@ -307,8 +307,8 @@ func (c *Cmd) Wait() error { if err != nil { return err - } else if !msg.Exited() || msg.ExitStatus() != 0 { - return &ExitError{msg} + } else if !state.Success() { + return &ExitError{state} } return copyError -- cgit v1.3