MCPcopy
hub / github.com/cloudflare/tableflip / File

Method File

fds.go:359–379  ·  view source on GitHub ↗

File returns an inherited file or nil. The descriptor may be in blocking mode.

(name string)

Source from the content-addressed store, hash-verified

357//
358// The descriptor may be in blocking mode.
359func (f *Fds) File(name string) (*os.File, error) {
360 f.mu.Lock()
361 defer f.mu.Unlock()
362
363 key := fileName{fdKind, name}
364 file := f.inherited[key]
365 if file == nil {
366 return nil, nil
367 }
368
369 // Make a copy of the file, since we don't want to
370 // allow the caller to invalidate fds in f.inherited.
371 dup, err := dupFd(file.fd, key)
372 if err != nil {
373 return nil, err
374 }
375
376 delete(f.inherited, key)
377 f.used[key] = file
378 return dup.File, nil
379}
380
381// AddFile adds a file.
382func (f *Fds) AddFile(name string, file *os.File) error {

Callers 2

childProcessFunction · 0.45
TestFdsFileFunction · 0.45

Calls 1

dupFdFunction · 0.70

Tested by 2

childProcessFunction · 0.36
TestFdsFileFunction · 0.36