Expand description
Process-group helpers shared by pipe/pty and shell command execution.
This module centralizes the 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)kill_process_grouptargets a known process group ID directly instead of a single PID.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.
On non-Unix platforms these helpers are no-ops.
Functionsยง
- detach_
from_ tty - Detach from the controlling TTY by starting a new session.
- interrupt_
process_ group - Send SIGINT to a specific process group ID (best-effort).
- kill_
child_ process_ group - Kill the process group for a tokio child (best-effort).
- 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).
- set_
parent_ death_ signal - Ensure the child receives SIGTERM when the original parent dies.
- set_
process_ group - Put the calling process into its own process group.
- terminate_
process_ group - Send SIGTERM to a specific process group ID (best-effort).