]> Cypherpunks repositories - gostls13.git/commitdiff
os: document that users of Fd should keep f alive
authorRuss Cox <rsc@golang.org>
Thu, 6 Nov 2014 14:36:51 +0000 (09:36 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 6 Nov 2014 14:36:51 +0000 (09:36 -0500)
Fixes #9046.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/162680043

src/os/file_plan9.go
src/os/file_unix.go
src/os/file_windows.go

index 5efc2a4f1dbb375f9f8db90c0dc177ea04309e14..132594eede9c6d34b9f1b305d116f6e82c8b6db8 100644 (file)
@@ -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))
index f59d563e697f032e020ac17020810a87b95584c1..ff4fc7d12e8b37fac34d0f123c8b137b085bfe55 100644 (file)
@@ -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))
index 3b5519390ba338dce0e1a3cebbb6905027564ddb..2a90a50559d17615b5bb1f8bf8732c28df0d4b4f 100644 (file)
@@ -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)