diff options
author | Joe Wilm <joe@jwilm.com> | 2016-06-08 21:24:31 -0700 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-06-08 21:24:31 -0700 |
commit | 8b1e82f31a7ecaade440b0694c0bbe5a843b48ac (patch) | |
tree | 0fb2e4fac0183490b62a663b9ca165e7a5e4bd0f /src/main.rs | |
parent | 8126841ed37a9cc249f646b830b3d3d48aaf4ed7 (diff) | |
download | r-alacritty-8b1e82f31a7ecaade440b0694c0bbe5a843b48ac.tar.gz r-alacritty-8b1e82f31a7ecaade440b0694c0bbe5a843b48ac.tar.bz2 r-alacritty-8b1e82f31a7ecaade440b0694c0bbe5a843b48ac.zip |
Fix shutdown deadlock
Calling ::std::process::exit() from the SIGCHLD handler would sometimes
deadlock some OpenGL internal shutdown procedure. To resolve this, a
flag was added that can be checked with `process_should_exit`.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 7c130bc4..94cc1bc1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,6 +44,7 @@ use grid::Grid; use term::Term; use meter::Meter; use util::thread; +use tty::process_should_exit; #[derive(Debug, Eq, PartialEq, Copy, Clone, Default)] pub struct Rgb { @@ -130,7 +131,7 @@ fn main() { } let (chars_tx, chars_rx) = ::std::sync::mpsc::channel(); - thread::spawn_named("TTY Reader", move || { + let reader_thread = thread::spawn_named("TTY Reader", move || { for c in reader.chars() { let c = c.unwrap(); chars_tx.send(c).unwrap(); @@ -219,8 +220,13 @@ fn main() { window.swap_buffers().unwrap(); } + + if process_should_exit() { + break; + } } - // TODO handle child cleanup + reader_thread.join(); + println!("Goodbye"); } |