Files
QSfera/vendor/github.com/gookit/goutil/sysutil/process/process_windows.go
T
2023-04-19 20:24:34 +02:00

29 lines
460 B
Go

package process
import (
"golang.org/x/sys/windows"
)
const (
processQueryLimitedInformation = 0x1000
stillActive = 259
)
// Exists check process running by given pid
func Exists(pid int) bool {
h, err := windows.OpenProcess(processQueryLimitedInformation, false, uint32(pid))
if err != nil {
return false
}
var c uint32
err = windows.GetExitCodeProcess(h, &c)
_ = windows.Close(h)
if err != nil {
return c == stillActive
}
return true
}