diff options
| author | Paul Buetow (europa) <paul@buetow.org> | 2015-05-24 21:10:43 +0100 |
|---|---|---|
| committer | Paul Buetow (europa) <paul@buetow.org> | 2015-05-24 21:10:43 +0100 |
| commit | 8ff768026dfa04d2e1a2c9c9f4cd8b08642004fa (patch) | |
| tree | c703eb2dbb2c1137fe85a2dd00e659ce549ebee3 /main | |
| parent | 645d431ba55d26c540ce63d54369dd43c5b43a2c (diff) | |
add packages
Diffstat (limited to 'main')
| -rw-r--r-- | main/main.go | 47 |
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") +} |
