containerd/util/fds.go
Burcu Dogan ec1169fe85 Build prctl on systems with procfs, fix fds build tag
Signed-off-by: Burcu Dogan <jbd@google.com>
2016-01-20 21:58:40 -08:00

18 lines
352 B
Go

// +build !windows,!darwin
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
}