mirror of
https://github.com/wez/wezterm.git
synced 2024-11-23 23:21:08 +03:00
fixup process termination detection on windows
This commit is contained in:
parent
ad41cecd6e
commit
400a85befc
@ -246,6 +246,8 @@ impl GuiEventLoop {
|
||||
loop {
|
||||
match self.tick_rx.try_recv() {
|
||||
Ok(_) => {
|
||||
#[cfg(not(unix))]
|
||||
self.test_for_child_exit();
|
||||
self.do_paint();
|
||||
}
|
||||
Err(TryRecvError::Empty) => return Ok(()),
|
||||
@ -261,20 +263,7 @@ impl GuiEventLoop {
|
||||
loop {
|
||||
match self.sigchld_rx.try_recv() {
|
||||
Ok(_) => {
|
||||
let window_ids: Vec<WindowId> = self
|
||||
.windows
|
||||
.borrow_mut()
|
||||
.by_id
|
||||
.iter_mut()
|
||||
.filter_map(|(window_id, window)| match window.test_for_child_exit() {
|
||||
Ok(_) => None,
|
||||
Err(_) => Some(*window_id),
|
||||
})
|
||||
.collect();
|
||||
|
||||
for window_id in window_ids {
|
||||
self.schedule_window_close(window_id)?;
|
||||
}
|
||||
self.test_for_child_exit();
|
||||
}
|
||||
Err(TryRecvError::Empty) => return Ok(()),
|
||||
Err(err) => bail!("paster_rx disconnected {:?}", err),
|
||||
@ -282,6 +271,23 @@ impl GuiEventLoop {
|
||||
}
|
||||
}
|
||||
|
||||
fn test_for_child_exit(&self) {
|
||||
let window_ids: Vec<WindowId> = self
|
||||
.windows
|
||||
.borrow_mut()
|
||||
.by_id
|
||||
.iter_mut()
|
||||
.filter_map(|(window_id, window)| match window.test_for_child_exit() {
|
||||
Ok(_) => None,
|
||||
Err(_) => Some(*window_id),
|
||||
})
|
||||
.collect();
|
||||
|
||||
for window_id in window_ids {
|
||||
self.schedule_window_close(window_id).ok();
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs the winit event loop. This blocks until a wakeup signal
|
||||
/// is delivered to the event loop. The `GuiSender` is our way
|
||||
/// of trigger those wakeups.
|
||||
|
@ -13,6 +13,7 @@ use winpty::winapi::shared::minwindef::DWORD;
|
||||
use winpty::winapi::shared::winerror::{HRESULT, S_OK};
|
||||
use winpty::winapi::um::fileapi::{ReadFile, WriteFile};
|
||||
use winpty::winapi::um::handleapi::*;
|
||||
use winpty::winapi::um::minwinbase::STILL_ACTIVE;
|
||||
use winpty::winapi::um::namedpipeapi::CreatePipe;
|
||||
use winpty::winapi::um::processthreadsapi::*;
|
||||
use winpty::winapi::um::winbase::EXTENDED_STARTUPINFO_PRESENT;
|
||||
@ -291,7 +292,11 @@ impl Child {
|
||||
let mut status: DWORD = 0;
|
||||
let res = unsafe { GetExitCodeProcess(self.proc.handle, &mut status) };
|
||||
if res != 0 {
|
||||
Ok(Some(ExitStatus { status }))
|
||||
if status == STILL_ACTIVE {
|
||||
Ok(None)
|
||||
} else {
|
||||
Ok(Some(ExitStatus { status }))
|
||||
}
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user