github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/pkg/pidfile/pidfile_windows.go (about)

     1  package pidfile
     2  
     3  import (
     4  	"golang.org/x/sys/windows"
     5  )
     6  
     7  const (
     8  	processQueryLimitedInformation = 0x1000
     9  
    10  	stillActive = 259
    11  )
    12  
    13  func processExists(pid int) bool {
    14  	h, err := windows.OpenProcess(processQueryLimitedInformation, false, uint32(pid))
    15  	if err != nil {
    16  		return false
    17  	}
    18  	var c uint32
    19  	err = windows.GetExitCodeProcess(h, &c)
    20  	windows.Close(h)
    21  	if err != nil {
    22  		return c == stillActive
    23  	}
    24  	return true
    25  }