github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/engine/pkg/fileutils/fileutils_unix.go (about) 1 //go:build linux || freebsd 2 // +build linux freebsd 3 4 package fileutils // import "github.com/docker/docker/pkg/fileutils" 5 6 import ( 7 "fmt" 8 "os" 9 10 "github.com/sirupsen/logrus" 11 ) 12 13 // GetTotalUsedFds Returns the number of used File Descriptors by 14 // reading it via /proc filesystem. 15 func GetTotalUsedFds() int { 16 if fds, err := os.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil { 17 logrus.Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err) 18 } else { 19 return len(fds) 20 } 21 return -1 22 }