1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-28 07:55:03 +03:00

wire up sigchld

This commit is contained in:
Wez Furlong 2018-02-21 23:51:52 -08:00
parent df0e85abaf
commit 8cb8d7d613
2 changed files with 25 additions and 1 deletions

View File

@ -426,4 +426,19 @@ impl TerminalWindow {
pub fn need_paint(&self) -> bool {
self.terminal.has_dirty_lines()
}
pub fn test_for_child_exit(&mut self) -> Result<(), Error> {
match self.process.try_wait() {
Ok(Some(status)) => {
bail!("child exited: {}", status);
}
Ok(None) => {
println!("child still running");
Ok(())
}
Err(e) => {
bail!("failed to wait for child: {}", e);
}
}
}
}

View File

@ -93,6 +93,9 @@ fn run_glium(
let poll = Poll::new()?;
poll.register(&master, Token(0), Ready::readable(), PollOpt::edge())?;
let waiter = sigchld::ChildWaiter::new()?;
poll.register(&waiter, Token(2), Ready::readable(), PollOpt::edge())?;
let mut events_loop = glium::glutin::EventsLoop::new();
let mut window = gliumwindows::TerminalWindow::new(
@ -120,7 +123,13 @@ fn run_glium(
if poll.poll(&mut events, Some(Duration::new(0, 2000)))? != 0 {
for event in &events {
if event.token() == Token(0) && event.readiness().is_readable() {
window.handle_pty_readable_event();
window.handle_pty_readable_event()?;
}
if event.token() == Token(2) {
println!("sigchld ready");
let pid = waiter.read_one()?;
println!("got sigchld from pid {}", pid);
window.test_for_child_exit()?;
}
}
} else if window.need_paint() {