Use a better package name for utility functions.
This commit is contained in:
parent
8c38c931b0
commit
f611b37834
5 changed files with 10 additions and 10 deletions
18
osutils/fds.go
Normal file
18
osutils/fds.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
// +build !windows,!darwin
|
||||
|
||||
package osutils
|
||||
|
||||
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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue