├── .gitignore ├── .travis.yml ├── LICENSE.md ├── README.md ├── Vagrantfile ├── go.mod ├── process.go ├── process_darwin.go ├── process_darwin_test.go ├── process_freebsd.go ├── process_linux.go ├── process_solaris.go ├── process_test.go ├── process_unix.go ├── process_unix_test.go └── process_windows.go /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant/ 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | arch: 2 | - amd64 3 | - ppc64le 4 | 5 | language: go 6 | 7 | go: 8 | - 1.13 9 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Mitchell Hashimoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Process List Library for Go [![GoDoc](https://godoc.org/github.com/mitchellh/go-ps?status.png)](https://godoc.org/github.com/mitchellh/go-ps) 2 | 3 | go-ps is a library for Go that implements OS-specific APIs to list and 4 | manipulate processes in a platform-safe way. The library can find and 5 | list processes on Linux, Mac OS X, Solaris, and Windows. 6 | 7 | If you're new to Go, this library has a good amount of advanced Go educational 8 | value as well. It uses some advanced features of Go: build tags, accessing 9 | DLL methods for Windows, cgo for Darwin, etc. 10 | 11 | How it works: 12 | 13 | * **Darwin** uses the `sysctl` syscall to retrieve the process table. 14 | * **Unix** uses the procfs at `/proc` to inspect the process tree. 15 | * **Windows** uses the Windows API, and methods such as 16 | `CreateToolhelp32Snapshot` to get a point-in-time snapshot of 17 | the process table. 18 | 19 | ## Installation 20 | 21 | Install using standard `go get`: 22 | 23 | ``` 24 | $ go get github.com/mitchellh/go-ps 25 | ... 26 | ``` 27 | 28 | ## TODO 29 | 30 | Want to contribute? Here is a short TODO list of things that aren't 31 | implemented for this library that would be nice: 32 | 33 | * FreeBSD support 34 | * Plan9 support 35 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 8 | config.vm.box = "chef/ubuntu-12.04" 9 | 10 | config.vm.provision "shell", inline: $script 11 | 12 | ["vmware_fusion", "vmware_workstation"].each do |p| 13 | config.vm.provider "p" do |v| 14 | v.vmx["memsize"] = "1024" 15 | v.vmx["numvcpus"] = "2" 16 | v.vmx["cpuid.coresPerSocket"] = "1" 17 | end 18 | end 19 | end 20 | 21 | $script = <