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 - Detach from the controlling TTY by starting a new session.
- graceful_
kill_ process_ group - Gracefully terminate a process group by PID.
- graceful_
kill_ process_ group_ default - Gracefully terminate a process group with default settings.
- kill_
child_ process_ group - Kill the process group for a tokio child (best-effort).
- kill_
child_ process_ group_ with_ signal - Kill the process group for a tokio child with a specific signal.
- kill_
process - No-op on non-Windows platforms.
- kill_
process_ group - Kill a specific process group ID (best-effort).
- kill_
process_ group_ by_ pid - Kill the process group for the given PID (best-effort).
- kill_
process_ group_ by_ pid_ with_ signal - Kill the process group for the given PID with a specific signal.
- kill_
process_ group_ with_ signal - Kill a specific process group ID with a specific signal.
- set_
parent_ death_ signal - No-op on non-Linux platforms.
- set_
process_ group - Put the calling process into its own process group.