1234567891011121314151617181920 |
- package fileutils
- import (
- "context"
- "fmt"
- "os"
- "github.com/containerd/containerd/log"
- )
- // GetTotalUsedFds Returns the number of used File Descriptors by
- // reading it via /proc filesystem.
- func GetTotalUsedFds() int {
- if fds, err := os.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil {
- log.G(context.TODO()).Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err)
- } else {
- return len(fds)
- }
- return -1
- }
|