1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/vendor/gotest.tools/v3/icmd/exitcode.go
Sebastiaan van Stijn fdd2772547
vendor: gotest.tools v3.2.0
full diff: https://github.com/gotestyourself/gotest.tools/compare/v3.1.0...v3.2.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-05-28 12:18:22 +02:00

24 lines
346 B
Go

package icmd
import (
"errors"
exec "golang.org/x/sys/execabs"
)
func processExitCode(err error) int {
if err == nil {
return 0
}
var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
if exitErr.ProcessState == nil {
return 0
}
if code := exitErr.ProcessState.ExitCode(); code != -1 {
return code
}
}
return 127
}