]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: report correct fcntl syscall error in checkCloseonexec
authorTobias Klauser <tklauser@distanz.ch>
Wed, 17 May 2023 07:38:20 +0000 (09:38 +0200)
committerGopher Robot <gobot@golang.org>
Fri, 19 May 2023 13:50:58 +0000 (13:50 +0000)
runtime.fcntl returns the error value as a negative value, so it needs
to be inverted before being converted to syscall.Errno.

Change-Id: I43cd0b035150424ac59e623b17a9396c7d62c186
Reviewed-on: https://go-review.googlesource.com/c/go/+/495675
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/runtime/nbpipe_test.go

index bb21003c358239f141254bcab3aa4c8791156dfa..378257261d13db76da414a574f5f5c9323b59fbb 100644 (file)
@@ -67,7 +67,7 @@ func checkCloseonexec(t *testing.T, fd int32, name string) {
        t.Helper()
        flags := runtime.Fcntl(fd, syscall.F_GETFD, 0)
        if flags < 0 {
-               t.Errorf("fcntl(%s, F_GETFD) failed: %v", name, syscall.Errno(flags))
+               t.Errorf("fcntl(%s, F_GETFD) failed: %v", name, syscall.Errno(-flags))
        } else if flags&syscall.FD_CLOEXEC == 0 {
                t.Errorf("FD_CLOEXEC not set in %s flags %#x", name, flags)
        }