Mirror signal deaths from real-time signals

This commit is contained in:
2026-11-04 02:57:49 +01:00
parent 599d86ccbf
commit 7465af5d41
2 changed files with 19 additions and 6 deletions
+4 -6
View File
@@ -194,12 +194,10 @@ pub fn exit_with_status(status: ExitStatus) -> ! {
}
fn kill_self_with(number: i32) -> ! {
if let Ok(signal) = Signal::try_from(number) {
let _ = prctl::set_dumpable(false);
let _ = unsafe { signal::signal(signal, SigHandler::SigDfl) };
let _ = SigSet::from(signal).thread_unblock();
let _ = signal::raise(signal);
}
let _ = prctl::set_dumpable(false);
unsafe { libc::signal(number, libc::SIG_DFL) };
let _ = to_sigset([number]).thread_unblock();
unsafe { libc::raise(number) };
process::exit(128 + number)
}
+15
View File
@@ -50,6 +50,21 @@ fn forwarded_signal_death_of_entrypoint_is_mirrored() {
assert_eq!(status.signal(), Some(libc::SIGTERM));
}
#[test]
fn forwarded_realtime_signal_death_of_entrypoint_is_mirrored() {
let dir = TempDir::new().expect("failed to create temp dir");
let realtime = libc::SIGRTMIN() + 1;
let script = ": > ready
sleep 60";
let (_sandbox, mut child) = spawn_sandbox(&["--blacklist"], dir.path(), script);
wait_for_file(&dir.path().join("ready"));
send_signal(&child, realtime);
let status = child.wait().unwrap();
assert_eq!(status.signal(), Some(realtime));
}
#[test]
fn user_and_realtime_signals_reach_entrypoint() {
let dir = TempDir::new().expect("failed to create temp dir");