]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR go/86331 (the gccgo's "go" tool looks like failing to invoke any sub go command)
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 2 Jul 2018 16:29:24 +0000 (16:29 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 2 Jul 2018 16:29:24 +0000 (16:29 +0000)
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

From-SVN: r262315

libgo/go/os/wait_waitid.go

index 3337395510e421d8bfd305005e09603943b7dc05..6eb487b11af0470315cbce076d4977df98f3aea6 100644 (file)
@@ -25,9 +25,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.