2017-08-14 14:28:08 -04:00
|
|
|
package icmd
|
|
|
|
|
|
|
|
import (
|
2022-09-22 09:38:19 -04:00
|
|
|
"errors"
|
2017-08-14 14:28:08 -04:00
|
|
|
|
2022-03-01 10:51:15 -05:00
|
|
|
exec "golang.org/x/sys/execabs"
|
2017-08-14 14:28:08 -04:00
|
|
|
)
|
|
|
|
|
2022-09-22 09:38:19 -04:00
|
|
|
func processExitCode(err error) int {
|
2017-08-14 14:28:08 -04:00
|
|
|
if err == nil {
|
|
|
|
return 0
|
|
|
|
}
|
2022-09-22 09:38:19 -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-14 14:28:08 -04:00
|
|
|
}
|
2022-09-22 09:38:19 -04:00
|
|
|
return 127
|
2017-08-14 14:28:08 -04:00
|
|
|
}
|