2017-08-14 14:28:08 -04:00
|
|
|
package icmd
|
|
|
|
|
|
|
|
import (
|
2022-09-22 09:38:19 -04:00
|
|
|
"errors"
|
2022-11-05 18:25:29 -04:00
|
|
|
"os/exec"
|
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
|
|
|
}
|