mirror of
https://github.com/wez/wezterm.git
synced 2024-12-28 07:55:03 +03:00
pty: speculative fixup of win32 build
This commit is contained in:
parent
7926c31209
commit
a65a4af9a7
@ -223,7 +223,7 @@ struct ProcessSignaller {
|
||||
pid: Option<u32>,
|
||||
|
||||
#[cfg(windows)]
|
||||
handle: Option<OwnedHandle>,
|
||||
handle: Option<filedescriptor::OwnedHandle>,
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
@ -301,6 +301,7 @@ impl ChildKiller for std::process::Child {
|
||||
|
||||
#[cfg(windows)]
|
||||
fn clone_killer(&self) -> Box<dyn ChildKiller + Send + Sync> {
|
||||
use std::os::windows::prelude::AsRawHandle;
|
||||
struct RawDup(RawHandle);
|
||||
impl AsRawHandle for RawDup {
|
||||
fn as_raw_handle(&self) -> RawHandle {
|
||||
@ -313,7 +314,7 @@ impl ChildKiller for std::process::Child {
|
||||
handle: self
|
||||
.as_raw_handle()
|
||||
.as_ref()
|
||||
.and_then(|h| OwnedHandle::dup(&RawDup(*h)).ok()),
|
||||
.and_then(|h| filedescriptor::OwnedHandle::dup(&RawDup(*h)).ok()),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -50,17 +50,45 @@ impl WinChild {
|
||||
}
|
||||
}
|
||||
|
||||
impl ChildKiller for WinChild {
|
||||
fn kill(&mut self) -> IoResult<()> {
|
||||
self.do_kill().ok();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn clone_killer(&self) -> Box<dyn ChildKiller + Send + Sync> {
|
||||
let proc = self.proc.lock().unwrap().try_clone().unwrap();
|
||||
Box::new(WinChildKiller { proc })
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct WinChildKiller {
|
||||
proc: OwnedHandle,
|
||||
}
|
||||
|
||||
impl ChildKiller for WinChildKiller {
|
||||
fn kill(&mut self) -> IoResult<()> {
|
||||
let res = unsafe { TerminateProcess(self.proc.as_raw_handle(), 1) };
|
||||
let err = IoError::last_os_error();
|
||||
if res != 0 {
|
||||
Err(err)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn clone_killer(&self) -> Box<dyn ChildKiller + Send + Sync> {
|
||||
let proc = self.proc.try_clone().unwrap();
|
||||
Box::new(WinChildKiller { proc })
|
||||
}
|
||||
}
|
||||
|
||||
impl Child for WinChild {
|
||||
fn try_wait(&mut self) -> IoResult<Option<ExitStatus>> {
|
||||
self.is_complete()
|
||||
}
|
||||
|
||||
fn kill(&mut self) -> IoResult<()> {
|
||||
self.do_kill().ok();
|
||||
self.wait()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn wait(&mut self) -> IoResult<ExitStatus> {
|
||||
if let Ok(Some(status)) = self.try_wait() {
|
||||
return Ok(status);
|
||||
|
Loading…
Reference in New Issue
Block a user