containerd/sys/fds.go
Michael Crosby 51510a8806 Move osutil to sys package
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-11-29 15:38:24 -08:00

18 lines
351 B
Go

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