mirror of
https://github.com/DominicBreuker/pspy.git
synced 2025-12-21 11:44:51 +00:00
integrate inotify syscalls
This commit is contained in:
25
internal/inotify/watcher.go
Normal file
25
internal/inotify/watcher.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package inotify
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const events = unix.IN_ALL_EVENTS
|
||||
|
||||
type watcher struct {
|
||||
wd int
|
||||
dir string
|
||||
}
|
||||
|
||||
func newWatcher(fd int, dir string, ping chan struct{}) (*watcher, error) {
|
||||
wd, errno := unix.InotifyAddWatch(fd, dir, events)
|
||||
if wd == -1 {
|
||||
return nil, fmt.Errorf("adding watcher on %s: %d", dir, errno)
|
||||
}
|
||||
return &watcher{
|
||||
wd: wd,
|
||||
dir: dir,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user