github.com/elastic/gosigar@v0.14.3/psnotify/README.md (about) 1 # Process notifications for Go 2 3 ## Overview 4 5 The psnotify package captures process events from the kernel via 6 kqueue on Darwin/BSD and the netlink connector on Linux. 7 8 The psnotify API is similar to the 9 [fsnotify](https://github.com/howeyc/fsnotify) package. 10 11 Example: 12 ```go 13 watcher, err := psnotify.NewWatcher() 14 if err != nil { 15 log.Fatal(err) 16 } 17 18 // Process events 19 go func() { 20 for { 21 select { 22 case ev := <-watcher.Fork: 23 log.Println("fork event:", ev) 24 case ev := <-watcher.Exec: 25 log.Println("exec event:", ev) 26 case ev := <-watcher.Exit: 27 log.Println("exit event:", ev) 28 case err := <-watcher.Error: 29 log.Println("error:", err) 30 } 31 } 32 }() 33 34 err = watcher.Watch(os.Getpid(), psnotify.PROC_EVENT_ALL) 35 if err != nil { 36 log.Fatal(err) 37 } 38 39 /* ... do stuff ... */ 40 watcher.Close() 41 ``` 42 43 ## Supported platforms 44 45 Currently targeting modern flavors of Darwin and Linux. 46 Should work on BSD, but untested. 47 48 ## License 49 50 Apache 2.0