Debian Codegraph @

src/os/wait_wait6.go

raw
1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build dragonfly || freebsd || netbsd
6
7 package os
8
9 import (
10 "runtime"
11 "syscall"
12 )
13
14 // blockUntilWaitable attempts to block until a call to p.Wait will
15 // succeed immediately, and reports whether it has done so.
16 // It does not actually call p.Wait.
17 func (p *Process) blockUntilWaitable() (bool, error) {
18 err := ignoringEINTR(func() error {
19 _, errno := wait6(_P_PID, p.Pid, syscall.WEXITED|syscall.WNOWAIT)
20 if errno != 0 {
21 return errno
22 }
23 return nil
24 })
25 runtime.KeepAlive(p)
26 if err == syscall.ENOSYS {
27 return false, nil
28 } else if err != nil {
29 return false, NewSyscallError("wait6", err)
30 }
31 return true, nil
32 }