replace_current_process

Function replace_current_process 

Source
pub async fn replace_current_process(
    env: &mut Env,
    path: CString,
    args: Vec<Field>,
) -> Result<Infallible, ReplaceCurrentProcessError>
Expand description

Substitutes the currently executing shell process with the external utility.

This function performs the very last step of the simple command execution. It disables the internal signal dispositions and calls the execve system call. If the call fails, it updates env.exit_status and returns an error, in which case the caller should print an error message and terminate the current process with the exit status.

If the execve call fails with ENOEXEC, this function falls back on invoking the shell with the given arguments, so that the shell can interpret the script. The path to the shell executable is taken from System::shell_path.

If the execve call succeeds, the future returned by this function never resolves.

This function is for implementing the simple command execution semantics and the exec built-in utility.