本文整理汇总了Golang中os.ProcessState.Success方法的典型用法代码示例。如果您正苦于以下问题:Golang ProcessState.Success方法的具体用法?Golang ProcessState.Success怎么用?Golang ProcessState.Success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os.ProcessState
的用法示例。
在下文中一共展示了ProcessState.Success方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetErrorLevel
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
}
}
示例2: Wait
// 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
}