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

Method Files

fds.go:329–354  ·  view source on GitHub ↗

Files returns all inherited files and mark them as used. The descriptors may be in blocking mode.

()

Source from the content-addressed store, hash-verified

327//
328// The descriptors may be in blocking mode.
329func (f *Fds) Files() ([]*os.File, error) {
330 f.mu.Lock()
331 defer f.mu.Unlock()
332
333 var files []*os.File
334
335 for key, file := range f.inherited {
336 if key[0] != fdKind {
337 continue
338 }
339
340 // Make a copy of the file, since we don't want to
341 // allow the caller to invalidate fds in f.inherited.
342 dup, err := dupFd(file.fd, key)
343 if err != nil {
344 return nil, err
345 }
346
347 f.used[key] = file
348 delete(f.inherited, key)
349
350 files = append(files, dup.File)
351 }
352
353 return files, nil
354}
355
356// File returns an inherited file or nil.
357//

Callers 1

TestFdsFilesFunction · 0.80

Calls 1

dupFdFunction · 0.70

Tested by 1

TestFdsFilesFunction · 0.64