github.com/georgethebeatle/containerd@v0.2.5/osutils/fds.go (about) 1 // +build !windows,!darwin 2 3 package osutils 4 5 import ( 6 "io/ioutil" 7 "path/filepath" 8 "strconv" 9 ) 10 11 // GetOpenFds returns the number of open fds for the process provided by pid 12 func GetOpenFds(pid int) (int, error) { 13 dirs, err := ioutil.ReadDir(filepath.Join("/proc", strconv.Itoa(pid), "fd")) 14 if err != nil { 15 return -1, err 16 } 17 return len(dirs), nil 18 }