anonymous 5b151eab4f fix #2 | 6 gadi atpakaļ | |
---|---|---|
.. | ||
README.md | 12 gadi atpakaļ | |
psnotify.go | 8 gadi atpakaļ | |
psnotify_bsd.go | 12 gadi atpakaļ | |
psnotify_linux.go | 6 gadi atpakaļ | |
psnotify_test.go | 8 gadi atpakaļ |
The psnotify package captures process events from the kernel via kqueue on Darwin/BSD and the netlink connector on Linux.
The psnotify API is similar to the fsnotify package.
Example:
watcher, err := psnotify.NewWatcher()
if err != nil {
log.Fatal(err)
}
// Process events
go func() {
for {
select {
case ev := <-watcher.Fork:
log.Println("fork event:", ev)
case ev := <-watcher.Exec:
log.Println("exec event:", ev)
case ev := <-watcher.Exit:
log.Println("exit event:", ev)
case err := <-watcher.Error:
log.Println("error:", err)
}
}
}()
err = watcher.Watch(os.Getpid(), psnotify.PROC_EVENT_ALL)
if err != nil {
log.Fatal(err)
}
/* ... do stuff ... */
watcher.Close()
Currently targeting modern flavors of Darwin and Linux. Should work on BSD, but untested.
Apache 2.0