aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2017-05-20 00:35:43 -0400
committerJoe Wilm <jwilm@users.noreply.github.com>2017-05-24 10:56:50 -0700
commit876dc151527cac0db1c319af0f0c95158bdf1806 (patch)
tree51ace88a9ad56896b671a6f88e99e711a575a773 /src/main.rs
parent262c70be573d4511b89305e8bea2306b028bc924 (diff)
downloadalacritty-876dc151527cac0db1c319af0f0c95158bdf1806.tar.gz
alacritty-876dc151527cac0db1c319af0f0c95158bdf1806.zip
Ensure that the event loop thread cleanly exits on shutdown
Background: If a shell process exits with children still alive (typically due to the `disown` shell builtin), POLLHUP will not be sent to the master PTY file descriptor. This is due to the fact that the disowned process still has the slave PTY open as its STDIN, STDOUT, and STDERR. If a disowned process never reads or writes from its file descriptors (which is often the case for graphical applications), the event loop will end up blocking on poll()/select() when not handling user input received over the mio channel. When Alacritty shuts down and joins on the event loop thread, there can never be any more input on the mio channel - the main thread is no longer handling user keystrokes from the window. Unless a disowned process happens to access its slave PTY file descriptors, the event loop will never get the chance to deetect that it should exit. This commit extends the `Msg` enum to include an explicit `Shutdown` message, which ensures a clean shutdown (e.g. closing the 'recording' file). This allows the select()/poll() call to remain blocking, instead of needing to periodically check the shutdown state in between timed-out calls. Fixes #339
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 5126b09d..7c377f2b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -29,7 +29,7 @@ use alacritty::cli;
use alacritty::config::{self, Config};
use alacritty::display::Display;
use alacritty::event;
-use alacritty::event_loop::{self, EventLoop};
+use alacritty::event_loop::{self, EventLoop, Msg};
use alacritty::logging;
use alacritty::sync::FairMutex;
use alacritty::term::{Term};
@@ -126,7 +126,7 @@ fn run(mut config: Config, options: cli::Options) -> Result<(), Box<Error>> {
//
// Need the Rc<RefCell<_>> here since a ref is shared in the resize callback
let mut processor = event::Processor::new(
- event_loop::Notifier(loop_tx),
+ event_loop::Notifier(event_loop.channel()),
display.resize_channel(),
&options,
&config,
@@ -178,6 +178,8 @@ fn run(mut config: Config, options: cli::Options) -> Result<(), Box<Error>> {
}
}
+ loop_tx.send(Msg::Shutdown).expect("Error sending shutdown to event loop");
+
// FIXME patch notify library to have a shutdown method
// config_reloader.join().ok();