From c0e3bdfb705d74ce7dfa0f2f563fb82d5454b952 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 2 Jun 2019 18:27:15 -0700 Subject: [PATCH] termwiz: avoid emitting a wake event on a spurious pipe wakeup --- termwiz/src/terminal/unix.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/termwiz/src/terminal/unix.rs b/termwiz/src/terminal/unix.rs index 62fc676942c..995bac54600 100644 --- a/termwiz/src/terminal/unix.rs +++ b/termwiz/src/terminal/unix.rs @@ -457,8 +457,10 @@ impl Terminal for UnixTerminal { if pfd[2].revents != 0 { let mut buf = [0u8; 64]; - if self.wake_pipe.read(&mut buf).is_ok() { - return Ok(Some(InputEvent::Wake)); + if let Ok(n) = self.wake_pipe.read(&mut buf) { + if n > 0 { + return Ok(Some(InputEvent::Wake)); + } } }