From 8ff768026dfa04d2e1a2c9c9f4cd8b08642004fa Mon Sep 17 00:00:00 2001 From: "Paul Buetow (europa)" Date: Sun, 24 May 2015 21:10:43 +0100 Subject: add packages --- main/main.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 main/main.go (limited to 'main/main.go') diff --git a/main/main.go b/main/main.go new file mode 100644 index 0000000..b8b5d39 --- /dev/null +++ b/main/main.go @@ -0,0 +1,47 @@ +package main + +import ( + "fmt" + "github.com/buetow/gstat/process" +) + +const ( + STOP = 0 + GETPIDS = 1 +) + +func gstatGather(action <-chan int, res chan<- process.Process) { + for { + switch <-action { + case STOP: + { + break + } + case GETPIDS: + { + process.Gather(res) + } + } + close(res) + } +} + +func main() { + action := make(chan int) + res := make(chan process.Process) + + go gstatGather(action, res) + + action <- GETPIDS + for { + process, more := <-res + if more { + fmt.Println(process.Cmdline) + } else { + break + } + } + action <- STOP + + fmt.Println("Good bye") +} -- cgit v1.2.3