diff options
Diffstat (limited to 'alacritty_terminal/src/tty/windows/child.rs')
-rw-r--r-- | alacritty_terminal/src/tty/windows/child.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/alacritty_terminal/src/tty/windows/child.rs b/alacritty_terminal/src/tty/windows/child.rs index dc6b992c..573eb475 100644 --- a/alacritty_terminal/src/tty/windows/child.rs +++ b/alacritty_terminal/src/tty/windows/child.rs @@ -1,6 +1,7 @@ use std::ffi::c_void; use std::io::Error; use std::num::NonZeroU32; +use std::ptr; use std::sync::atomic::{AtomicPtr, Ordering}; use std::sync::{mpsc, Arc, Mutex}; @@ -50,7 +51,7 @@ pub struct ChildExitWatcher { wait_handle: AtomicPtr<c_void>, event_rx: mpsc::Receiver<ChildEvent>, interest: Arc<Mutex<Option<Interest>>>, - child_handle: HANDLE, + child_handle: AtomicPtr<c_void>, pid: Option<NonZeroU32>, } @@ -58,12 +59,12 @@ impl ChildExitWatcher { pub fn new(child_handle: HANDLE) -> Result<ChildExitWatcher, Error> { let (event_tx, event_rx) = mpsc::channel(); - let mut wait_handle: HANDLE = 0; + let mut wait_handle: HANDLE = ptr::null_mut(); let interest = Arc::new(Mutex::new(None)); let sender_ref = Box::new(ChildExitSender { sender: event_tx, interest: interest.clone(), - child_handle: AtomicPtr::from(child_handle as *mut c_void), + child_handle: AtomicPtr::from(child_handle), }); let success = unsafe { @@ -82,11 +83,11 @@ impl ChildExitWatcher { } else { let pid = unsafe { NonZeroU32::new(GetProcessId(child_handle)) }; Ok(ChildExitWatcher { - wait_handle: AtomicPtr::from(wait_handle as *mut c_void), event_rx, interest, - child_handle, pid, + child_handle: AtomicPtr::from(child_handle), + wait_handle: AtomicPtr::from(wait_handle), }) } } @@ -112,7 +113,7 @@ impl ChildExitWatcher { /// If you terminate the process using this handle, the terminal will get a /// timeout error, and the child watcher will emit an `Exited` event. pub fn raw_handle(&self) -> HANDLE { - self.child_handle + self.child_handle.load(Ordering::Relaxed) as HANDLE } /// Retrieve the Process ID associated to the underlying child process. |