mirror of
https://github.com/DominicBreuker/pspy.git
synced 2025-12-21 11:44:51 +00:00
try some more tsting
This commit is contained in:
30
internal/fswatcher/inotify/watcher.go
Normal file
30
internal/fswatcher/inotify/watcher.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package inotify
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const maximumWatchersFile = "/proc/sys/fs/inotify/max_user_watches"
|
||||
|
||||
type Watcher struct {
|
||||
WD int
|
||||
Dir string
|
||||
}
|
||||
|
||||
func GetLimit() (int, error) {
|
||||
b, err := ioutil.ReadFile(maximumWatchersFile)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("reading from %s: %v", maximumWatchersFile, err)
|
||||
}
|
||||
|
||||
s := strings.TrimSpace(string(b))
|
||||
m, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("converting to integer: %v", err)
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
Reference in New Issue
Block a user