diff --git a/loader/loader.go b/loader/loader.go index 28f969e5..42347013 100644 --- a/loader/loader.go +++ b/loader/loader.go @@ -16,7 +16,6 @@ import ( "path/filepath" "strconv" "strings" - "syscall" "github.com/tinygo-org/tinygo/cgo" "github.com/tinygo-org/tinygo/compileopts" @@ -110,10 +109,7 @@ func Load(config *compileopts.Config, inputPkgs []string, clangHeaders string, t err = cmd.Run() if err != nil { if exitErr, ok := err.(*exec.ExitError); ok { - if status, ok := exitErr.Sys().(syscall.WaitStatus); ok { - os.Exit(status.ExitStatus()) - } - os.Exit(1) + os.Exit(exitErr.ExitCode()) } return nil, fmt.Errorf("failed to run `go list`: %s", err) } diff --git a/main.go b/main.go index 2e22920e..dbcbc4d8 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,6 @@ import ( "runtime" "strings" "sync/atomic" - "syscall" "time" "github.com/mattn/go-colorable" @@ -166,10 +165,7 @@ func Test(pkgName string, options *compileopts.Options, testCompileOnly bool, ou if err != nil { // Propagate the exit code if err, ok := err.(*exec.ExitError); ok { - if status, ok := err.Sys().(syscall.WaitStatus); ok { - os.Exit(status.ExitStatus()) - } - os.Exit(1) + os.Exit(err.ExitCode()) } return &commandError{"failed to run compiled binary", result.Binary, err} } @@ -1080,10 +1076,7 @@ func main() { err = cmd.Run() if err != nil { if exitErr, ok := err.(*exec.ExitError); ok { - if status, ok := exitErr.Sys().(syscall.WaitStatus); ok { - os.Exit(status.ExitStatus()) - } - os.Exit(1) + os.Exit(exitErr.ExitCode()) } fmt.Fprintln(os.Stderr, "failed to run `go list`:", err) os.Exit(1)