blob: ddd3f7045ecda8ad8b243293c747115caa020cab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package util
import (
"os"
"syscall"
)
// ProcessIsRunning tell is a process is running
func ProcessIsRunning(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
}
|