From 62c1d999e1361fc68ee4e54865b205415fa0a38d Mon Sep 17 00:00:00 2001 From: Rachel K Date: Tue, 12 Mar 2019 19:44:47 +0000 Subject: Fix signal handling on Unix systems This removes the the signal handling machinery in tty::unix, and replaces it with functionality from signal-hook, which should be more robust. Signals caught by signal-hook wake up the existing I/O event loop, which then delegates back to the PTY to handle them. In particular, this allows `SIGCHLD` (i.e. child process exits) to shut down the terminal promptly, instead of sometimes leaving the window lingering. Fixes #915. Fixes #1276. Fixes #1313. As a side effect, this fixes a very rare bug on Linux, where a `read` from the PTY on the master side would sometimes "fail" with `EIO` if the child closed the client side at a particular moment. This was subject to a race condition, and was very difficult to trigger in practice. --- src/tty/windows/mod.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/tty/windows/mod.rs') diff --git a/src/tty/windows/mod.rs b/src/tty/windows/mod.rs index 5e0aee84..2f5caa93 100644 --- a/src/tty/windows/mod.rs +++ b/src/tty/windows/mod.rs @@ -28,7 +28,7 @@ use crate::cli::Options; use crate::config::Config; use crate::display::OnResize; use crate::term::SizeInfo; -use crate::tty::EventedReadWrite; +use crate::tty::{EventedReadWrite, EventedPty}; mod conpty; mod winpty; @@ -232,12 +232,12 @@ impl<'a> EventedReadWrite for Pty<'a> { fn register( &mut self, poll: &mio::Poll, - token: &mut dyn Iterator, + token: &mut dyn Iterator, interest: mio::Ready, poll_opts: mio::PollOpt, ) -> io::Result<()> { - self.read_token = (*token.next().unwrap()).into(); - self.write_token = (*token.next().unwrap()).into(); + self.read_token = token.next().unwrap(); + self.write_token = token.next().unwrap(); if interest.is_readable() { poll.register( @@ -339,3 +339,5 @@ impl<'a> EventedReadWrite for Pty<'a> { self.write_token } } + +impl<'a> EventedPty for Pty<'a> { } -- cgit