Files
i3status-go/vendor/go.i3wm.org/i3/validpid.go
2024-01-06 18:33:44 +03:00

17 lines
409 B
Go

package i3
import "syscall"
func pidValid(pid int) bool {
// As per kill(2) from POSIX.1-2008, sending signal 0 validates a pid.
if err := syscall.Kill(pid, 0); err != nil {
if err == syscall.EPERM {
// Process still alive (but no permission to signal):
return true
}
// errno is likely ESRCH (process not found).
return false // Process not alive.
}
return true // Process still alive.
}