diff options
author | Michael Muré <batolettre@gmail.com> | 2018-09-11 22:04:16 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-09-11 22:14:46 +0200 |
commit | 3605887345792d2f981f971c6c4a2cb7f86a343e (patch) | |
tree | afd525b6e3a638e4c619a5a986fcb2811c297444 /util/process/process.go | |
parent | 7b05983c19af4da70f2a9a5062913f4e4f5d5faa (diff) | |
download | git-bug-3605887345792d2f981f971c6c4a2cb7f86a343e.tar.gz |
reorganize package for a more idomatic go
Diffstat (limited to 'util/process/process.go')
-rw-r--r-- | util/process/process.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/util/process/process.go b/util/process/process.go new file mode 100644 index 00000000..f3bcb7f2 --- /dev/null +++ b/util/process/process.go @@ -0,0 +1,23 @@ +package process + +import ( + "os" + "syscall" +) + +// IsRunning tell is a process is running +func IsRunning(pid int) bool { + // never return no error in a unix system + process, err := os.FindProcess(pid) + + if err != nil { + return false + } + + // Signal 0 doesn't do anything but allow testing the process + err = process.Signal(syscall.Signal(0)) + + // Todo: distinguish "you don't have access" and "process doesn't exist" + + return err == nil +} |