Expand description
Process-group helpers for reliable child process cleanup.
This module centralizes OS-specific pieces that ensure a spawned command can be cleaned up reliably:
set_process_groupis called inpre_execso the child starts its own process group.detach_from_ttystarts a new session so non-interactive children do not inherit the controlling TTY.kill_process_group_by_pidtargets the whole group (children/grandchildren) instead of a single PID.kill_process_grouptargets a known process group ID directly.set_parent_death_signal(Linux only) arranges for the child to receive aSIGTERMwhen the parent exits, and re-checks the parent PID to avoid races during fork/exec.graceful_kill_process_groupsends SIGTERM, waits for a grace period, then SIGKILL if still running.
On non-Unix platforms these helpers are no-ops or adapted equivalents.
Inspired by codex-rs/utils/pty process group management patterns.
Enums§
- Graceful
Termination Result - Result of a graceful termination attempt.
- Kill
Signal - Signal to send when killing process groups.
Constants§
- DEFAULT_
GRACEFUL_ TIMEOUT_ MS - Default grace period for graceful termination (milliseconds).
Functions§
- detach_
from_ tty - No-op on non-Unix platforms.
- graceful_
kill_ process_ group - Graceful termination on non-Unix (best effort).
- graceful_
kill_ process_ group_ default - Graceful termination with defaults on non-Unix.
- kill_
child_ process_ group - No-op on non-Unix platforms.
- kill_
child_ process_ group_ with_ signal - No-op on non-Unix platforms.
- kill_
process - Kill a process by PID on Windows.
- kill_
process_ group - No-op on non-Unix platforms.
- kill_
process_ group_ by_ pid - No-op on non-Unix platforms.
- kill_
process_ group_ by_ pid_ with_ signal - No-op on non-Unix platforms.
- kill_
process_ group_ with_ signal - No-op on non-Unix platforms.
- set_
parent_ death_ signal - No-op on non-Linux platforms.
- set_
process_ group - No-op on non-Unix platforms.