aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/docker/docker/pkg/fileutils/fileutils_darwin.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/docker/docker/pkg/fileutils/fileutils_darwin.go')
-rw-r--r--vendor/github.com/docker/docker/pkg/fileutils/fileutils_darwin.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/github.com/docker/docker/pkg/fileutils/fileutils_darwin.go b/vendor/github.com/docker/docker/pkg/fileutils/fileutils_darwin.go
new file mode 100644
index 000000000..ccd648fac
--- /dev/null
+++ b/vendor/github.com/docker/docker/pkg/fileutils/fileutils_darwin.go
@@ -0,0 +1,27 @@
+package fileutils
+
+import (
+ "os"
+ "os/exec"
+ "strconv"
+ "strings"
+)
+
+// GetTotalUsedFds returns the number of used File Descriptors by
+// executing `lsof -p PID`
+func GetTotalUsedFds() int {
+ pid := os.Getpid()
+
+ cmd := exec.Command("lsof", "-p", strconv.Itoa(pid))
+
+ output, err := cmd.CombinedOutput()
+ if err != nil {
+ return -1
+ }
+
+ outputStr := strings.TrimSpace(string(output))
+
+ fds := strings.Split(outputStr, "\n")
+
+ return len(fds) - 1
+}