File: README.md

package info (click to toggle)
golang-github-cloudfoundry-gosigar 0.0~git20180907.50ddd08-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 352 kB
  • sloc: sh: 26; makefile: 4
file content (50 lines) | stat: -rw-r--r-- 1,117 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Process notifications for Go

## Overview

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](https://github.com/howeyc/fsnotify) package.

Example:
```go
    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()
```

## Supported platforms

Currently targeting modern flavors of Darwin and Linux.
Should work on BSD, but untested.

## License

Apache 2.0