From 6523632ade5e36b74a39b9ee8db2df1ef2be4461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 15 Oct 2026 00:42:30 -0400 Subject: [PATCH] pty: when its pty closes, a program that ignores SIGHUP reads EIO on Linux and EOF on macOS; the test reads the shell's own exit, which holds on both --- src/term/pty.rs | 3 ++- src/term/unix.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/term/pty.rs b/src/term/pty.rs index 38c9474..5f03e56 100644 --- a/src/term/pty.rs +++ b/src/term/pty.rs @@ -337,7 +337,8 @@ mod tests { #[test] fn a_program_that_ignores_sighup_ends_when_the_pty_closes() { - close_after_ready("trap '' HUP; printf READY; exec cat", "exit status: 0"); + // cat reads EOF on macOS and EIO on Linux; the shell's own exit holds on both. + close_after_ready("trap '' HUP; printf READY; cat; exit 7", "exit status: 7"); } #[test] diff --git a/src/term/unix.rs b/src/term/unix.rs index fa0bf03..6c688db 100644 --- a/src/term/unix.rs +++ b/src/term/unix.rs @@ -289,7 +289,7 @@ impl Drop for Pty { fn drop(&mut self) { unsafe { libc::kill(self.child.id() as libc::pid_t, libc::SIGHUP) }; unregister(self.sig); - // Closed before the wait, so a program that ignores SIGHUP reads EOF. + // Closed before the wait, so a program that ignores SIGHUP finds the terminal gone. unsafe { ManuallyDrop::drop(&mut self.file) }; match self.child.wait() { Ok(status) => log::info!("pty {}: hung up, {status}", self.id()),