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
This commit is contained in:
2 files changed
+3
-2
No files matched your search
+2
-1
@@ -337,7 +337,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_program_that_ignores_sighup_ends_when_the_pty_closes() {
|
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]
|
#[test]
|
||||||
|
|||||||
+1
-1
@@ -289,7 +289,7 @@ impl Drop for Pty {
|
|||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe { libc::kill(self.child.id() as libc::pid_t, libc::SIGHUP) };
|
unsafe { libc::kill(self.child.id() as libc::pid_t, libc::SIGHUP) };
|
||||||
unregister(self.sig);
|
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) };
|
unsafe { ManuallyDrop::drop(&mut self.file) };
|
||||||
match self.child.wait() {
|
match self.child.wait() {
|
||||||
Ok(status) => log::info!("pty {}: hung up, {status}", self.id()),
|
Ok(status) => log::info!("pty {}: hung up, {status}", self.id()),
|
||||||
|
|||||||
Reference in new issue
Block a user