Skip to main content

Module process_group

Module process_group 

Source
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_group is called in pre_exec so the child starts its own process group.
  • detach_from_tty starts a new session so non-interactive children do not inherit the controlling TTY.
  • kill_process_group_by_pid targets the whole group (children/grandchildren)
  • kill_process_group targets a known process group ID directly instead of a single PID.
  • set_parent_death_signal (Linux only) arranges for the child to receive a SIGTERM when 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).