processAlive reports whether a process with the given PID is currently running. FindProcess always succeeds on Unix, so liveness is probed with signal 0.
(pid int)
| 22 | // running. FindProcess always succeeds on Unix, so liveness is probed with |
| 23 | // signal 0. |
| 24 | func processAlive(pid int) bool { |
| 25 | if pid <= 0 { |
| 26 | return false |
| 27 | } |
| 28 | proc, err := os.FindProcess(pid) |
| 29 | if err != nil { |
| 30 | return false |
| 31 | } |
| 32 | return proc.Signal(syscall.Signal(0)) == nil |
| 33 | } |
| 34 | |
| 35 | // terminateDaemon stops the daemon on Unix with SIGTERM so it can shut down |
| 36 | // gracefully. This matches long-standing behavior and does not gate on |
no outgoing calls