Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package cmd
import (
"bufio"
"bytes"
"errors"
"os/exec"
"sync"
"syscall"
Expand Down Expand Up @@ -211,16 +210,11 @@ func (c *Cmd) run() {
signaled := false
if err != nil {
if exiterr, ok := err.(*exec.ExitError); ok {
err = nil // exec.ExitError isn't a standard error

if waitStatus, ok := exiterr.Sys().(syscall.WaitStatus); ok {
exitCode = waitStatus.ExitStatus() // -1 if signaled

// If the command was terminated by a signal, then exiterr.Error()
// is a string like "signal: terminated".
if waitStatus.Signaled() {
signaled = true
err = errors.New(exiterr.Error())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestCmdNonzeroExit(t *testing.T) {
PID: gotStatus.PID, // nondeterministic
Complete: true,
Exit: 1,
Error: nil,
Error: errors.New("exit status 1"),
Runtime: gotStatus.Runtime, // nondeterministic
Stdout: []string{},
Stderr: []string{},
Expand Down