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

Method FileDescriptors

proc.go:205–221  ·  view source on GitHub ↗

FileDescriptors returns the currently open file descriptors of a process.

()

Source from the content-addressed store, hash-verified

203
204// FileDescriptors returns the currently open file descriptors of a process.
205func (p Proc) FileDescriptors() ([]uintptr, error) {
206 names, err := p.fileDescriptors()
207 if err != nil {
208 return nil, err
209 }
210
211 fds := make([]uintptr, len(names))
212 for i, n := range names {
213 fd, err := strconv.ParseInt(n, 10, 32)
214 if err != nil {
215 return nil, fmt.Errorf("%w: Cannot parse line: %v: %w", ErrFileParse, i, err)
216 }
217 fds[i] = uintptr(fd)
218 }
219
220 return fds, nil
221}
222
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.

Callers 1

TestFileDescriptorsFunction · 0.80

Calls 1

fileDescriptorsMethod · 0.95

Tested by 1

TestFileDescriptorsFunction · 0.64