本文整理匯總了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
}