mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
os: document that users of Fd should keep f alive
Fixes #9046. LGTM=r R=r CC=golang-codereviews https://golang.org/cl/162680043
This commit is contained in:
parent
23ecad07cd
commit
1cdd9b407d
3 changed files with 4 additions and 1 deletions
|
|
@ -25,7 +25,8 @@ type file struct {
|
||||||
dirinfo *dirInfo // nil unless directory being read
|
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 {
|
func (f *File) Fd() uintptr {
|
||||||
if f == nil {
|
if f == nil {
|
||||||
return ^(uintptr(0))
|
return ^(uintptr(0))
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ type file struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fd returns the integer Unix file descriptor referencing the open file.
|
// 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 {
|
func (f *File) Fd() uintptr {
|
||||||
if f == nil {
|
if f == nil {
|
||||||
return ^(uintptr(0))
|
return ^(uintptr(0))
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ type file struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fd returns the Windows handle referencing the open file.
|
// 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 {
|
func (file *File) Fd() uintptr {
|
||||||
if file == nil {
|
if file == nil {
|
||||||
return uintptr(syscall.InvalidHandle)
|
return uintptr(syscall.InvalidHandle)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue