summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/main.go47
1 files changed, 47 insertions, 0 deletions
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")
+}