go_sysutils/exec_extra/func.go

14 lines
252 B
Go
Raw Normal View History

2020-09-26 02:17:33 -04:00
package exec_extra
import (
`os/exec`
)
func ExecCmdReturn(cmd *exec.Cmd) (exitStatus int, err error) {
// https://stackoverflow.com/a/55055100/733214
err = cmd.Run()
exitErr, _ := err.(*exec.ExitError)
exitStatus = exitErr.ExitCode()
return
}