Skip to main content

Module exec

Module exec 

Source
Expand description

Shell command execution with proper process tree management.

Provides platform-correct process spawning and cleanup:

  • Unix: spawns in a dedicated process group via process_group(0), kills with killpg(PGID, SIGKILL) to catch compound commands.
  • Windows: uses taskkill /F /T /PID to kill the entire process tree.

The kill_process_tree function is the key correctness primitive: bare child.kill() only terminates the shell process, leaving grandchildren (pipelines, && chains) alive as orphans.

Structs§

ShellResult
Result of a shell command execution with captured stderr.

Constants§

STDERR_CAPTURE_MAX
Maximum bytes of stderr captured from a shell command.

Functions§

kill_process_tree
Kill a child process and all its descendants.
run_with_timeout
Run a shell command with a timeout (seconds).
shell_command
Build a platform-appropriate shell command.