MCPcopy Create free account
hub / github.com/prometheus/procfs / FileDescriptorTargets

Method FileDescriptorTargets

proc.go:225–241  ·  view source on GitHub ↗

FileDescriptorTargets returns the targets of all file descriptors of a process. If a file descriptor is not a symlink to a file (like a socket), that value will be the empty string.

()

Source from the content-addressed store, hash-verified

223// FileDescriptorTargets returns the targets of all file descriptors of a process.
224// If a file descriptor is not a symlink to a file (like a socket), that value will be the empty string.
225func (p Proc) FileDescriptorTargets() ([]string, error) {
226 names, err := p.fileDescriptors()
227 if err != nil {
228 return nil, err
229 }
230
231 targets := make([]string, len(names))
232
233 for i, name := range names {
234 target, err := os.Readlink(p.path("fd", name))
235 if err == nil {
236 targets[i] = target
237 }
238 }
239
240 return targets, nil
241}
242
243// FileDescriptorsLen returns the number of currently open file descriptors of
244// a process.

Callers 1

Calls 2

fileDescriptorsMethod · 0.95
pathMethod · 0.95

Tested by 1