Files
docker-cli/components/engine/pkg/fileutils/fileutils_unix.go
John Howard af83f1caed Windows: Fix warning on info
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 8d56108ffb4e334600377c4bb4471eecec7b825c
Component: engine
2015-09-18 13:39:12 -07:00

23 lines
441 B
Go

// +build linux freebsd
package fileutils
import (
"fmt"
"io/ioutil"
"os"
"github.com/Sirupsen/logrus"
)
// GetTotalUsedFds Returns the number of used File Descriptors by
// reading it via /proc filesystem.
func GetTotalUsedFds() int {
if fds, err := ioutil.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil {
logrus.Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err)
} else {
return len(fds)
}
return -1
}