T04: close the pty master before reaping, so a program ignoring SIGHUP ends
CI / platforms (windows-latest) (push) Failing after 7s
CI / macos (push) Successful in 10m42s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

This commit is contained in:
ZacharyZhang-NY committed 2026-10-14 12:15:17 -04:00
1 parent fff436c8e9
commit 0e7f3095c3
2 files changed
+22 -13

No files matched your search

+14 -7
View File
@@ -269,14 +269,11 @@ mod tests {
assert_eq!(ran.text, format!("8 {}", u16::MAX / 8));
}
#[test]
fn closing_a_session_hangs_up_its_program() {
/// Starts `script`, waits for it to print READY, closes it, and waits for the reap's log.
fn close_after_ready(script: &str, reaped: &str) {
crate::testlog::init();
let launch = Launch {
program: Some((
"/bin/sh".into(),
vec!["-c".into(), "printf READY; exec cat".into()],
)),
program: Some(("/bin/sh".into(), vec!["-c".into(), script.into()])),
cwd: std::env::temp_dir(),
env: Vec::new(),
};
@@ -295,7 +292,7 @@ mod tests {
});
let pid = pty.pid;
drop(pty);
let hung_up = format!("pty {pid}: hung up, signal: 1 (SIGHUP)");
let hung_up = format!("pty {pid}: hung up, {reaped}");
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5);
while !crate::testlog::logged(&hung_up) {
assert!(std::time::Instant::now() < deadline, "no `{hung_up}`");
@@ -306,6 +303,16 @@ mod tests {
assert!(!alive, "the program was reaped");
}
#[test]
fn closing_a_session_hangs_up_its_program() {
close_after_ready("printf READY; exec cat", "signal: 1 (SIGHUP)");
}
#[test]
fn a_program_that_ignores_sighup_ends_when_the_pty_closes() {
close_after_ready("trap '' HUP; printf READY; exec cat", "exit status: 0");
}
#[test]
fn a_missing_folder_stops_the_start() {
let launch = Launch {