// succeed immediately, and reports whether it has done so.
// It does not actually call p.Wait.
func (p *Process) blockUntilWaitable() (bool, error) {
- var errno syscall.Errno
- for {
- _, errno = wait6(_P_PID, p.Pid, syscall.WEXITED|syscall.WNOWAIT)
- if errno != syscall.EINTR {
- break
- }
- }
+ err := ignoringEINTR(func() error {
+ _, errno := wait6(_P_PID, p.Pid, syscall.WEXITED|syscall.WNOWAIT)
+ return errno
+ })
runtime.KeepAlive(p)
- if errno == syscall.ENOSYS {
+ if err == syscall.ENOSYS {
return false, nil
- } else if errno != 0 {
- return false, NewSyscallError("wait6", errno)
+ } else if err != nil {
+ return false, NewSyscallError("wait6", err)
}
return true, nil
}
// We don't care about the values it returns.
var siginfo [16]uint64
psig := &siginfo[0]
- var e syscall.Errno
- for {
- _, _, e = syscall.Syscall6(syscall.SYS_WAITID, _P_PID, uintptr(p.Pid), uintptr(unsafe.Pointer(psig)), syscall.WEXITED|syscall.WNOWAIT, 0, 0)
- if e != syscall.EINTR {
- break
- }
- }
+ err := ignoringEINTR(func() error {
+ _, _, errno := syscall.Syscall6(syscall.SYS_WAITID, _P_PID, uintptr(p.Pid), uintptr(unsafe.Pointer(psig)), syscall.WEXITED|syscall.WNOWAIT, 0, 0)
+ return errno
+ })
runtime.KeepAlive(p)
- if e != 0 {
+ if err != nil {
// waitid has been available since Linux 2.6.9, but
// reportedly is not available in Ubuntu on Windows.
// See issue 16610.
- if e == syscall.ENOSYS {
+ if err == syscall.ENOSYS {
return false, nil
}
- return false, NewSyscallError("waitid", e)
+ return false, NewSyscallError("waitid", err)
}
return true, nil
}