diff options
Diffstat (limited to 'hello/hello.go')
-rw-r--r-- | hello/hello.go | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/hello/hello.go b/hello/hello.go deleted file mode 100644 index de496d7..0000000 --- a/hello/hello.go +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | package main | ||
2 | |||
3 | import ( | ||
4 | "fmt" | ||
5 | "syscall" | ||
6 | "time" | ||
7 | |||
8 | "netlink" | ||
9 | ) | ||
10 | |||
11 | func main() { | ||
12 | ns, err := netlink.NewNetlinkSocket(syscall.NETLINK_CONNECTOR, 12345) | ||
13 | if err != nil { | ||
14 | fmt.Printf("Error creating socket: %v\n", err) | ||
15 | } | ||
16 | defer ns.Close() | ||
17 | for { | ||
18 | res, err := ns.Receive() | ||
19 | if err != nil { | ||
20 | fmt.Printf("Error recv: %v\n", err) | ||
21 | continue | ||
22 | } | ||
23 | for i := 0; i < len(res); i++ { | ||
24 | procEvent := netlink.ParseProcEvent(res[i].Data) | ||
25 | switch procEvent.What { | ||
26 | case netlink.PROC_EVENT_FORK: | ||
27 | data := procEvent.Data.(netlink.ProcEventFork) | ||
28 | fmt.Printf("%v\tFork\t%d\t%d\t%d\t%d\n", time.Now(), data.ParentPid, data.ParentTgid, data.ChildPid, data.ChildTgid) | ||
29 | case netlink.PROC_EVENT_EXIT: | ||
30 | data := procEvent.Data.(netlink.ProcEventExit) | ||
31 | fmt.Printf("%v\tExit\t%d\t%d\t%d\t%d\n", time.Now(), data.ProcessPid, data.ProcessTgid, data.ExitCode, data.ExitSignal) | ||
32 | default: | ||
33 | } | ||
34 | } | ||
35 | } | ||
36 | } | ||