diff --git a/Cargo.lock b/Cargo.lock index 2a93243f..77f68150 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3463,7 +3463,7 @@ dependencies = [ "parking_lot", "signal-hook", "tracing", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/teletypewriter/Cargo.toml b/teletypewriter/Cargo.toml index 4b7e9b0d..414d5b12 100644 --- a/teletypewriter/Cargo.toml +++ b/teletypewriter/Cargo.toml @@ -19,7 +19,7 @@ signal-hook = "0.3.17" iovec = { workspace = true } [target.'cfg(windows)'.dependencies] -windows-sys = { version = "0.48", features = [ +windows-sys = { version = "0.59", features = [ "Win32_System_Console", "Win32_Foundation", "Win32_Security", diff --git a/teletypewriter/src/windows/child.rs b/teletypewriter/src/windows/child.rs index cd214e56..333eb5d0 100644 --- a/teletypewriter/src/windows/child.rs +++ b/teletypewriter/src/windows/child.rs @@ -29,11 +29,16 @@ pub struct ChildExitWatcher { pid: Option, } +// HANDLE is not Send, so Send is not derived automatically for ChildExitWatcher, but raw pointers +// are generally safe to send between threads as long as the type they deference to is Send, which +// c_void is. (see https://doc.rust-lang.org/nomicon/send-and-sync.html). +unsafe impl Send for ChildExitWatcher {} + impl ChildExitWatcher { pub fn new(child_handle: HANDLE) -> Result { let (event_tx, event_rx) = channel::(); - let mut wait_handle: HANDLE = 0; + let mut wait_handle: HANDLE = std::ptr::null_mut(); let sender_ref = Box::new(event_tx); let success = unsafe { diff --git a/teletypewriter/src/windows/conpty.rs b/teletypewriter/src/windows/conpty.rs index 004071ab..bb80f655 100644 --- a/teletypewriter/src/windows/conpty.rs +++ b/teletypewriter/src/windows/conpty.rs @@ -68,7 +68,7 @@ impl ConptyApi { type LoadedFn = unsafe extern "system" fn() -> isize; unsafe { let hmodule = LoadLibraryW(w!("conpty.dll")); - if hmodule == 0 { + if hmodule.is_null() { return None; } let create_fn = GetProcAddress(hmodule, s!("CreatePseudoConsole"))?; diff --git a/teletypewriter/src/windows/pipes.rs b/teletypewriter/src/windows/pipes.rs index f877a6e8..8253b6d6 100644 --- a/teletypewriter/src/windows/pipes.rs +++ b/teletypewriter/src/windows/pipes.rs @@ -201,7 +201,7 @@ impl Drop for EventedAnonRead { // Stop reader thread waiting for pipe contents unsafe { - CancelSynchronousIo(thread.as_raw_handle() as isize); + CancelSynchronousIo(thread.as_raw_handle()); } thread