unix: fix finalizer fd close bug in TestOpenByHandleAt The raw fd is successively wrapped using os.NewFile, so dont defer close the raw fd, but instead use (*os.File).Close. Fixes golang/go#49403 Change-Id: I1f4b12536ff0abea6b1680a4ff932b7eefa57162 Reviewed-on: https://go-review.googlesource.com/c/sys/+/361995 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/unix/syscall_linux_test.go b/unix/syscall_linux_test.go index f5d3966..910f579 100644 --- a/unix/syscall_linux_test.go +++ b/unix/syscall_linux_test.go
@@ -720,10 +720,10 @@ if err != nil { t.Fatalf("OpenByHandleAt: %v", err) } - defer unix.Close(fd) - t.Logf("opened fd %v", fd) f := os.NewFile(uintptr(fd), "") + defer f.Close() + slurp, err := ioutil.ReadAll(f) if err != nil { t.Fatal(err)