1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/pkg/pidfile/pidfile_windows.go
John Starks 9e5b93565c Windows: don't overwrite PID file if process exists
pidfile.New() was opening a file in /proc to determine if the owning
process still exists. Use syscall.OpenProcess() on Windows instead.

Other OSes may also need to be updated here.

Signed-off-by: John Starks <jostarks@microsoft.com>
2016-04-18 16:41:37 -07:00

23 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
}