Skip to main content

Module process

Module process 

Source
Expand description

Shell-free process groups and bounded I/O, extracted/adapted from route_agent.

Functions§

bounded_command
Runs argv without a shell in its own process group, writes input to its standard input, and returns its exit status, standard output and standard error. Fails with TimedOut after timeout, and when either stream exceeds maximum bytes. The group is killed when the command ends.
bounded_command_until
bounded_command that also stops the command’s process group, with an Interrupted error, as soon as abort returns true. The command runs in its own group, so a terminal’s SIGINT to the caller does not reach it.
drain
Keep draining beyond the limit to avoid pipe deadlocks; never retain excess bytes.
drain_file
Bounded on-disk diagnostics, with pipes drained after cap is reached.
group
Puts the command in a process group of its own, so that terminate_process_group also reaches its descendants.
group_stopped
Check Linux process-group membership, counting zombies as already stopped. Returns an error when liveness cannot be established. Escaped sessions are outside the foreground backend’s contract; use systemd for containment.
terminate_process_group
Kills the child’s process group with SIGKILL, then the child itself.