containerd/util/fds.go
Michael Crosby 6d3c60d8fb Add fd output to debug metrics
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-12-09 14:40:55 -08:00

16 lines
324 B
Go

package util
import (
"io/ioutil"
"path/filepath"
"strconv"
)
// GetOpenFds returns the number of open fds for the process provided by pid
func GetOpenFds(pid int) (int, error) {
dirs, err := ioutil.ReadDir(filepath.Join("/proc", strconv.Itoa(pid), "fd"))
if err != nil {
return -1, err
}
return len(dirs), nil
}