From 52c979bc0843dc2b820db97aaff8b58b6ad9d675 Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Tue, 14 Mar 2017 08:39:20 +0100 Subject: [PATCH] Fix hang on exit after child process failed Quick test (works ~50%) is to press Ctrl+C followed by Ctrl+D. Reproducible on Arch Linux with OpenGL from NVidia. Fixes #228 --- src/tty.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/tty.rs b/src/tty.rs index 7623abdc..eb0ba590 100644 --- a/src/tty.rs +++ b/src/tty.rs @@ -21,7 +21,7 @@ use std::os::unix::process::CommandExt; use std::ptr; use std::process::{Command, Stdio}; -use libc::{self, winsize, c_int, pid_t, WNOHANG, WIFEXITED, WEXITSTATUS, SIGCHLD, TIOCSCTTY}; +use libc::{self, winsize, c_int, pid_t, WNOHANG, SIGCHLD, TIOCSCTTY}; use term::SizeInfo; use display::OnResize; @@ -48,15 +48,9 @@ extern "C" fn sigchld(_a: c_int) { die!("Waiting for pid {} failed: {}\n", PID, errno()); } - if PID != p { - return; + if PID == p { + SHOULD_EXIT = true; } - - if !WIFEXITED(status) || WEXITSTATUS(status) != 0 { - die!("child finished with error '{}'\n", status); - } - - SHOULD_EXIT = true; } }