FileDescriptors returns the currently open file descriptors of a process.
()
| 203 | |
| 204 | // FileDescriptors returns the currently open file descriptors of a process. |
| 205 | func (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. |