zombie

command
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

README

Zombie Prevention Example

This example demonstrates how procio ensures child processes are cleaned up when the parent process exits manually or crashes.

How to Run

# Run the example (spawns a child process, then exits immediately)
go run examples/zombie/main.go

The output will look like (with LogProvider enabled):

INFO successfully opened Windows CONIN$ for interruptible reads
INFO initialized Windows Job Object for process hygiene
Parent starting child via proc.Start...
DEBUG assigned process to job object pid=12345
DEBUG metric incremented name=lifecycle_processes_started_total
Child PID: 12345. Parent exiting now.

Verification

To verify that the child process (PID 12345) has been terminated, check the process list.

Windows (PowerShell)
Get-Process -Id 12345
# Expected Output:
# Get-Process : Cannot find a process with the process identifier 12345.
Linux (Bash)
ps -p 12345
# Expected Output:
# PID TTY          TIME CMD
# (No lines output, meaning process is gone)

Internal Mechanism

  • Windows: Uses Job Objects with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE. When the parent process handle to the Job Object closes (at death), the OS automatically kills all associated children.
  • Linux: Uses PR_SET_PDEATHSIG to receive a SIGKILL when the parent dies, ensuring no residual processes.
  • Metrics: Each successful start is recorded via metrics.IncProcessStarted().

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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