2017-08-23 16:57:27 -04:00
|
|
|
package icmd
|
|
|
|
|
|
|
|
import (
|
2022-05-27 12:11:13 -04:00
|
|
|
"errors"
|
2017-08-23 16:57:27 -04:00
|
|
|
|
2022-03-01 11:02:53 -05:00
|
|
|
exec "golang.org/x/sys/execabs"
|
2017-08-23 16:57:27 -04:00
|
|
|
)
|
|
|
|
|
2022-05-27 12:11:13 -04:00
|
|
|
func processExitCode(err error) int {
|
2017-08-23 16:57:27 -04:00
|
|
|
if err == nil {
|
|
|
|
return 0
|
|
|
|
}
|
2022-05-27 12:11:13 -04:00
|
|
|
|
|
|
|
var exitErr *exec.ExitError
|
|
|
|
if errors.As(err, &exitErr) {
|
|
|
|
if exitErr.ProcessState == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
if code := exitErr.ProcessState.ExitCode(); code != -1 {
|
|
|
|
return code
|
|
|
|
}
|
2017-08-23 16:57:27 -04:00
|
|
|
}
|
2022-05-27 12:11:13 -04:00
|
|
|
return 127
|
2017-08-23 16:57:27 -04:00
|
|
|
}
|