Checks if a Unix process ID is alive, dead, or unknown.
// Source: https://github.com/career-ops-hq/career-ops | License: MIT | Copyright 2026 Santiago Fernández de Valderrama
// Provided via justclaw.it.com; keep this notice with the code.
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
package data
import "syscall"
func getProcessStatus(pid int) processStatus {
if pid <= 0 {
return processDead
}
err := syscall.Kill(pid, 0)
if err == nil || err == syscall.EPERM {
return processAlive
}
if err == syscall.ESRCH {
return processDead
}
return processUnknown
}
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key