Skip to main content

spawn_program

Function spawn_program 

Source
pub fn spawn_program<I, S>(program: &Path, arg0: &str, args: I) -> Command
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,
Expand description

Spawn a resolved program directly, skipping the shell.

The counterpart to spawn_shell for a script body that direct::direct_argv found to be a single plain command. program is the absolute path direct_argv resolved; arg0 is the program as written in the script body, passed through as argv[0] so the child sees what a shell would have given it.

Env parity with the shell path is structural, not a parallel list: this calls the same [apply_script_settings_env] and shares kill_on_drop. Which now kills the tool itself rather than a shell holding it as a child — strictly more direct, and the reason the Windows Job Object story in spawn_shell does not apply here (the fast path is Unix-only).