mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
24 lines
394 B
Go
24 lines
394 B
Go
|
package pidfile
|
||
|
|
||
|
import "syscall"
|
||
|
|
||
|
const (
|
||
|
processQueryLimitedInformation = 0x1000
|
||
|
|
||
|
stillActive = 259
|
||
|
)
|
||
|
|
||
|
func processExists(pid int) bool {
|
||
|
h, err := syscall.OpenProcess(processQueryLimitedInformation, false, uint32(pid))
|
||
|
if err != nil {
|
||
|
return false
|
||
|
}
|
||
|
var c uint32
|
||
|
err = syscall.GetExitCodeProcess(h, &c)
|
||
|
syscall.Close(h)
|
||
|
if err != nil {
|
||
|
return c == stillActive
|
||
|
}
|
||
|
return true
|
||
|
}
|