Skip to content

Commit d14a49d

Browse files
Add documentation about why we use exec
1 parent ddf0ba2 commit d14a49d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

build_system/src/rust_tools.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ impl RustcTools {
9999
fn exec(input: &[&dyn AsRef<OsStr>], env: &HashMap<String, String>) -> Result<(), String> {
100100
#[cfg(unix)]
101101
{
102+
// We use `exec` to call the `execvp` syscall instead of creating a new process where the
103+
// command will be executed because very few signals can actually kill a current process,
104+
// so if segmentation fault (SIGSEGV signal) happens and we raise to the current process,
105+
// it will simply do nothing and we won't have the nice error message for the shell.
102106
let error = crate::utils::get_command_inner(input, None, Some(env)).exec();
103107
eprintln!("execvp syscall failed: {error:?}");
104108
std::process::exit(1);

0 commit comments

Comments
 (0)