github.com/olljanat/moby@v1.13.1/pkg/pidfile/pidfile_windows.go (about)

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