Help us shape the future of Go! Take the 2026 Go Developer Survey

process

package
v1.0.65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package process provides cross-platform process-existence checks. Used by the bus daemon's stale-lock recovery path: bus.lock holds the daemon's PID; on startup a competing process reads that PID and calls Alive() to decide whether to abort (the holder is still running) or steal the lock (orphan).

On Unix this is the standard signal-0 trick (syscall.Kill(pid, 0)) which errors with ESRCH if the process is gone. On Windows it uses OpenProcess with PROCESS_QUERY_LIMITED_INFORMATION and GetExitCodeProcess to detect STILL_ACTIVE; this avoids the Unix-only assumption in plan §1.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alive

func Alive(pid int) bool

Alive reports whether a process with the given PID is currently running. Returns false for non-positive PIDs without performing any syscall.

On Unix this uses signal 0 (syscall.Kill(pid, 0)), which performs the normal permission/existence check without delivering a signal:

  • nil error → process exists and we have permission
  • syscall.EPERM → process exists but owned by another user (still counts as alive for our purpose)
  • syscall.ESRCH → no such process

Any other error is treated as "alive" defensively, so we never steal a lock based on an ambiguous syscall failure.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL