summaryrefslogtreecommitdiffhomepage
path: root/pkg/fd/fd.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/fd/fd.go')
-rw-r--r--pkg/fd/fd.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/pkg/fd/fd.go b/pkg/fd/fd.go
index f6656ffa1..a2edf2aa6 100644
--- a/pkg/fd/fd.go
+++ b/pkg/fd/fd.go
@@ -158,6 +158,9 @@ func New(fd int) *FD {
// The returned FD is always blocking (Go 1.9+).
func NewFromFile(file *os.File) (*FD, error) {
fd, err := syscall.Dup(int(file.Fd()))
+ // Technically, the runtime may call the finalizer on file as soon as
+ // Fd() returns.
+ runtime.KeepAlive(file)
if err != nil {
return &FD{ReadWriter{-1}}, err
}