pidfile_windows.go 394 B

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