MCPcopy Create free account
hub / github.com/git-bug/git-bug / IsRunning

Function IsRunning

util/process/process.go:9–33  ·  view source on GitHub ↗

IsRunning tell is a process is running

(pid int)

Source from the content-addressed store, hash-verified

7
8// IsRunning tell is a process is running
9func IsRunning(pid int) bool {
10 // never return no error in a unix system
11 process, err := os.FindProcess(pid)
12 if err != nil {
13 return false
14 }
15
16 // Signal 0 doesn't do anything but allow testing the process
17 err = process.Signal(syscall.Signal(0))
18 if err == nil {
19 return true
20 }
21 if err.Error() == "os: process already finished" {
22 return false
23 }
24 if errno, ok := err.(syscall.Errno); ok {
25 switch errno {
26 case syscall.ESRCH:
27 return false
28 case syscall.EPERM:
29 return true
30 }
31 }
32 return false
33}

Callers 1

repoIsAvailableFunction · 0.92

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected