From: Ian Lance Taylor Date: Mon, 2 Jul 2018 16:28:43 +0000 (+0000) Subject: re PR go/86331 (the gccgo's "go" tool looks like failing to invoke any sub go command) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7edd4c1885f4ecc31b80f157f7aa96ccd40d1075;p=gcc.git re PR go/86331 (the gccgo's "go" tool looks like failing to invoke any sub go command) 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: r262313 --- diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 237c46d9a66..e65c0bc574b 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -e1fcce0aec27b1f50ac0e736f39f4c806c2a5baa +94738979a3422e845acf358a766aabf8b9275d43 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. 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.