diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-07-02 16:28:58 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-07-02 16:28:58 +0000 |
commit | baa4d8cdc5c5608ae9a47ff19b594453d79ce507 (patch) | |
tree | ba2ac522f8af01dd98e2c5a84855bc67e7ec7d86 /libgo | |
parent | 65948c062e4e4b42b552d6c8a5e52380cd04b56c (diff) |
PR go/86331
os: check return value as well as error from waitid
https://gcc.gnu.org/PR86331 indicates that if a signal handler runs it
is possible for syscall.Syscall6 to return a non-zero errno value even
if no error occurs. That is a problem in general, but this fix will
let us work around the general problem for the specific case of
calling waitid.
Reviewed-on: https://go-review.googlesource.com/121595
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@262314 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/go/os/wait_waitid.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libgo/go/os/wait_waitid.go b/libgo/go/os/wait_waitid.go index 5a62b27f191..a6284aad98a 100644 --- a/libgo/go/os/wait_waitid.go +++ b/libgo/go/os/wait_waitid.go @@ -28,9 +28,12 @@ func (p *Process) blockUntilWaitable() (bool, error) { // We don't care about the values it returns. var siginfo [16]uint64 psig := &siginfo[0] - _, _, e := syscall.Syscall6(syscall.SYS_WAITID, _P_PID, uintptr(p.Pid), uintptr(unsafe.Pointer(psig)), syscall.WEXITED|syscall.WNOWAIT, 0, 0) + r, _, e := syscall.Syscall6(syscall.SYS_WAITID, _P_PID, uintptr(p.Pid), uintptr(unsafe.Pointer(psig)), syscall.WEXITED|syscall.WNOWAIT, 0, 0) runtime.KeepAlive(p) - if e != 0 { + // Check r as well as e because syscall.Syscall6 currently + // just returns errno, and the SIGCHLD signal handler may + // change errno. See https://gcc.gnu.org/PR86331. + if r != 0 && e != 0 { // waitid has been available since Linux 2.6.9, but // reportedly is not available in Ubuntu on Windows. // See issue 16610. |