diff options
author | Russ Cox <rsc@golang.org> | 2014-11-06 09:36:51 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-11-06 09:36:51 -0500 |
commit | 1cdd9b407db0f842387dc5e4f18e6563dcd87b18 (patch) | |
tree | 134a5ad5d21d7288dd4f348b371aa1b2e25c1490 | |
parent | 23ecad07cd8cf07a21af07a1e96803f32536ab05 (diff) | |
download | go-1cdd9b407db0f842387dc5e4f18e6563dcd87b18.tar.gz go-1cdd9b407db0f842387dc5e4f18e6563dcd87b18.zip |
os: document that users of Fd should keep f alive
Fixes #9046.
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/162680043
-rw-r--r-- | src/os/file_plan9.go | 3 | ||||
-rw-r--r-- | src/os/file_unix.go | 1 | ||||
-rw-r--r-- | src/os/file_windows.go | 1 |
3 files changed, 4 insertions, 1 deletions
diff --git a/src/os/file_plan9.go b/src/os/file_plan9.go index 5efc2a4f1d..132594eede 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 f59d563e69..ff4fc7d12e 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 3b5519390b..2a90a50559 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) |