From 87a8f70ba7cf934bf5e5f17f69f0a2203cc03563 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Wed, 5 Nov 2014 20:25:20 -0800 Subject: os/exec: tell lsof not to block For some reason lsof is now hanging on my workstation without the -b (avoid blocking in the kernel) option. Adding -b makes the test pass and shouldn't hurt. I don't know how recent the -b option is. If the builders are ok with it, it's probably ok. LGTM=rsc R=golang-codereviews, bradfitz, rsc CC=golang-codereviews https://codereview.appspot.com/166220043 --- src/os/exec/exec_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/os') diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go index bc9c00eff..197d3e8b4 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go @@ -246,7 +246,7 @@ func TestPipeLookPathLeak(t *testing.T) { } func numOpenFDS(t *testing.T) (n int, lsof []byte) { - lsof, err := exec.Command("lsof", "-n", "-p", strconv.Itoa(os.Getpid())).Output() + lsof, err := exec.Command("lsof", "-b", "-n", "-p", strconv.Itoa(os.Getpid())).Output() if err != nil { t.Skip("skipping test; error finding or running lsof") } -- cgit v1.2.1 From c5c528a7ea701534b4e5d5590e46f69f2f893f43 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 6 Nov 2014 09:36:51 -0500 Subject: os: document that users of Fd should keep f alive Fixes issue 9046. LGTM=r R=r CC=golang-codereviews https://codereview.appspot.com/162680043 --- src/os/file_plan9.go | 3 ++- src/os/file_unix.go | 1 + src/os/file_windows.go | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/os') diff --git a/src/os/file_plan9.go b/src/os/file_plan9.go index 5efc2a4f1..132594eed 100644 --- a/src/os/file_plan9.go +++ b/src/os/file_plan9.go @@ -25,7 +25,8 @@ type file struct { dirinfo *dirInfo // nil unless directory being read } -// Fd returns the integer Unix file descriptor referencing the open file. +// Fd returns the integer Plan 9 file descriptor referencing the open file. +// The file descriptor is valid only until f.Close is called or f is garbage collected. func (f *File) Fd() uintptr { if f == nil { return ^(uintptr(0)) diff --git a/src/os/file_unix.go b/src/os/file_unix.go index f59d563e6..ff4fc7d12 100644 --- a/src/os/file_unix.go +++ b/src/os/file_unix.go @@ -29,6 +29,7 @@ type file struct { } // Fd returns the integer Unix file descriptor referencing the open file. +// The file descriptor is valid only until f.Close is called or f is garbage collected. func (f *File) Fd() uintptr { if f == nil { return ^(uintptr(0)) diff --git a/src/os/file_windows.go b/src/os/file_windows.go index 3b5519390..2a90a5055 100644 --- a/src/os/file_windows.go +++ b/src/os/file_windows.go @@ -36,6 +36,7 @@ type file struct { } // Fd returns the Windows handle referencing the open file. +// The handle is valid only until f.Close is called or f is garbage collected. func (file *File) Fd() uintptr { if file == nil { return uintptr(syscall.InvalidHandle) -- cgit v1.2.1