Source file src/os/wait_waitid.go
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 // We used to use this code for Darwin, but according to issue #19314 6 // waitid returns if the process is stopped, even when using WEXITED. 7 8 //go:build linux 9 10 package os 11 12 import ( 13 "internal/syscall/unix" 14 "runtime" 15 "syscall" 16 ) 17 18 // blockUntilWaitable attempts to block until a call to p.Wait will 19 // succeed immediately, and reports whether it has done so. 20 // It does not actually call p.Wait. 21 func (p *Process) blockUntilWaitable() (bool, error) { 22 var info unix.SiginfoChild 23 err := ignoringEINTR(func() error { 24 return unix.Waitid(unix.P_PID, p.Pid, &info, syscall.WEXITED|syscall.WNOWAIT, nil) 25 }) 26 runtime.KeepAlive(p) 27 if err != nil { 28 // waitid has been available since Linux 2.6.9, but 29 // reportedly is not available in Ubuntu on Windows. 30 // See issue 16610. 31 if err == syscall.ENOSYS { 32 return false, nil 33 } 34 return false, NewSyscallError("waitid", err) 35 } 36 return true, nil 37 } 38