mirror of https://github.com/golang/go.git
os: use ignoringEINTR in (*Process).blockUntilWaitable
Instead of open-coding it. Change-Id: I7430066550a82e5d69846a1ec08b74474207c006 Reviewed-on: https://go-review.googlesource.com/c/go/+/627478 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
parent
3ca78afb3b
commit
42e2abd110
|
|
@ -15,18 +15,15 @@ import (
|
|||
// 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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,22 +27,19 @@ func (p *Process) blockUntilWaitable() (bool, error) {
|
|||
// 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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue