You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you kill the rust-script process it will not pass the kill signal to the child process with a compiled binary. With the way I use rust-script, this leaves me with a few stale processes that I have to clean up manually.
It's easy to address this for unix (although that'll likely disrupt deferred cache cleanup)
Example diff
diff --git a/src/main.rs b/src/main.rs
index 6ea81a3..c97b3fc 100644
--- a/src/main.rs+++ b/src/main.rs@@ -27,6 +27,7 @@ use serde::{Deserialize, Serialize};
use std::ffi::OsString;
use std::fs;
use std::io::{Read, Write};
+use std::os::unix::process::CommandExt;
use std::path::{Path, PathBuf};
use std::process::Command;
@@ -481,18 +482,17 @@ fn try_main() -> MainResult<i32> {
})
};
- let exit_code = if action.execute {+ if action.execute {
let cmd_name = action.build_kind.exec_command();
info!("running `cargo {}`", cmd_name);
let run_quietly = !action.cargo_output;
let mut cmd = action.cargo(cmd_name, &args.script_args, run_quietly)?;
- cmd.status().map(|st| st.code().unwrap_or(1))?+ let err = cmd.exec();+ Err(MainError::from(err))
} else {
- 0- };-- Ok(exit_code)+ Ok(0)+ }
}
/**
For reference: we transitioned to unix exec in 445d9cf last year - leaving this open for the Windows part (contributions are welcome, as I don't know much Windows myself).
fornwall
changed the title
rust-script can leave orphaned child processes when killed
rust-script can leave orphaned child processes when killed on Windows
Mar 24, 2023
If you kill the
rust-script
process it will not pass the kill signal to the child process with a compiled binary. With the way I userust-script
, this leaves me with a few stale processes that I have to clean up manually.It's easy to address this for unix (although that'll likely disrupt deferred cache cleanup)
Example diff
and not so much for Windows: see implementation used by
cargo run
or wexecvp-based implementation suggested forexec
crate.The text was updated successfully, but these errors were encountered: