diff options
Diffstat (limited to 'src/shims/mod.rs')
| -rw-r--r-- | src/shims/mod.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/shims/mod.rs b/src/shims/mod.rs index 32ae7c9..5560aa3 100644 --- a/src/shims/mod.rs +++ b/src/shims/mod.rs @@ -147,6 +147,24 @@ pub fn record(tool: &str, args: &[String]) { } } +/// Test hook: kill the process that invoked us, mid-step, with a signal it +/// cannot catch. This is how the crash-resume invariant (I5) is tested for real: +/// the pipeline process dies while a step is running, with no chance to clean +/// up, and the next process must pick up from the checkpoints. +fn kill_parent_if_asked(tool: &str) { + let want = std::env::var("AUR_SHIM_KILL_PARENT").unwrap_or_default(); + if want == tool { + // Flush the invocation log first (record() already closed the file), + // then murder the parent. No cleanup, no unwinding, no atexit. + unsafe { + libc::kill(libc::getppid(), libc::SIGKILL); + } + // If the kill somehow did not land, do not let the step complete — that + // would make the test silently test nothing. + std::process::exit(137); + } +} + /// True when the harness asked this tool to fail. fn forced_fail(tool: &str) -> bool { std::env::var("AUR_SHIM_FAIL").map(|v| v == tool).unwrap_or(false) @@ -182,6 +200,7 @@ pub fn called_with(dir: &Path, tool: &str, needle: &str) -> usize { pub fn run(tool: &str) -> i32 { let args: Vec<String> = std::env::args().skip(1).collect(); record(tool, &args); + kill_parent_if_asked(tool); let m = manifest(); let r = match tool { "mkarchroot" => mkarchroot(&args), |
