Exemplo n.º 1
0
// Wait calls Wait on the underlying exec.Cmd's Process and, if the
// operating system supports it, returns the exit status.
//
// If an error occurs when waiting for the underlying process, the exit
// status will be -2, and the error will be returned.  If the operating
// system does not support determining the exit status, but the program
// exited successfully, the exit status will be 0.  If the operating
// system does not support determining the exit status and the program
// exited unsuccessfully, the exit status will be -1.
func (p *Proc) Wait() (exitStatus int, err error) {
	var ps *os.ProcessState
	ps, err = p.Cmd.Process.Wait()
	if err != nil {
		return -2, err
	}
	ws, ok := ps.Sys().(syscall.WaitStatus)
	if ok {
		return ws.ExitStatus(), nil
	}
	if ps.Success() {
		return 0, nil
	}
	return -1, nil
}
Exemplo n.º 2
0
func getExitCode(state *os.ProcessState) int {
	return state.Sys().(syscall.WaitStatus).ExitStatus()
}
Exemplo n.º 3
0
func exitStatus(p *os.ProcessState) int {
	ws := p.Sys().(syscall.WaitStatus)
	return ws.ExitStatus()
}
Exemplo n.º 4
-4
func GetErrorLevel(processState *os.ProcessState) (int, bool) {
	if processState.Success() {
		return 0, true
	} else if t, ok := processState.Sys().(syscall.WaitStatus); ok {
		return t.ExitStatus(), true
	} else {
		return 255, false
	}
}