From 690f0b8836495dbf7c5b8d9b83c05f312bad12cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denizhan=20Dak=C4=B1l=C4=B1r?= Date: Fri, 9 Jan 2026 15:02:20 +0300 Subject: [PATCH 1/2] fix: add Win32_Storage_FileSystem feature and improve handle closing logic --- crates/uv-trampoline/Cargo.toml | 1 + crates/uv-trampoline/src/bounce.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/crates/uv-trampoline/Cargo.toml b/crates/uv-trampoline/Cargo.toml index 6a16fa8f9a7cd..8f0a705796639 100644 --- a/crates/uv-trampoline/Cargo.toml +++ b/crates/uv-trampoline/Cargo.toml @@ -47,6 +47,7 @@ windows = { version = "0.61.0", features = [ "Win32_System_LibraryLoader", "Win32_System_Threading", "Win32_UI_WindowsAndMessaging", + "Win32_Storage_FileSystem", ] } ufmt-write = "0.1.0" ufmt = { version = "0.2.0", features = ["std"] } diff --git a/crates/uv-trampoline/src/bounce.rs b/crates/uv-trampoline/src/bounce.rs index c1fb236eb4615..d74ea06ed357a 100644 --- a/crates/uv-trampoline/src/bounce.rs +++ b/crates/uv-trampoline/src/bounce.rs @@ -8,6 +8,7 @@ use windows::Win32::{ Foundation::{ CloseHandle, HANDLE, HANDLE_FLAG_INHERIT, INVALID_HANDLE_VALUE, SetHandleInformation, TRUE, }, + Storage::FileSystem::{GetFileType, FILE_TYPE_PIPE}, System::Console::{ GetStdHandle, STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, SetConsoleCtrlHandler, SetStdHandle, }, @@ -345,6 +346,9 @@ fn close_handles(si: &STARTUPINFOA) { // Unlike cleanup_standard_io(), we don't close STD_ERROR_HANDLE to retain warn! for std_handle in [STD_INPUT_HANDLE, STD_OUTPUT_HANDLE] { if let Ok(handle) = unsafe { GetStdHandle(std_handle) } { + if handle.is_invalid() || unsafe { GetFileType(handle) } != FILE_TYPE_PIPE { + continue; + } unsafe { CloseHandle(handle) }.unwrap_or_else(|_| { warn!("Failed to close standard device handle {}", handle.0 as u32); }); From 2fd2544ca04af5c2776ebbe25d97297a29016cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denizhan=20Dak=C4=B1l=C4=B1r?= Date: Fri, 9 Jan 2026 15:12:00 +0300 Subject: [PATCH 2/2] format --- crates/uv-trampoline/src/bounce.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/uv-trampoline/src/bounce.rs b/crates/uv-trampoline/src/bounce.rs index d74ea06ed357a..23ee6b8f032fa 100644 --- a/crates/uv-trampoline/src/bounce.rs +++ b/crates/uv-trampoline/src/bounce.rs @@ -8,7 +8,7 @@ use windows::Win32::{ Foundation::{ CloseHandle, HANDLE, HANDLE_FLAG_INHERIT, INVALID_HANDLE_VALUE, SetHandleInformation, TRUE, }, - Storage::FileSystem::{GetFileType, FILE_TYPE_PIPE}, + Storage::FileSystem::{FILE_TYPE_PIPE, GetFileType}, System::Console::{ GetStdHandle, STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, SetConsoleCtrlHandler, SetStdHandle, },