From 3a486c1feb0a4846a3bcff0dda5182dc9c762ba2 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Sun, 19 Nov 2023 16:24:39 +0000 Subject: [PATCH] Use an absolute path to the NUL device While a bare "NUL" *should* be redirected to the NUL device, especially in this simple case, let's be explicit that we aren't opening a file called "NUL" and instead open it directly. This will also set a good example for people copying std code. --- library/std/src/sys/windows/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/windows/process.rs b/library/std/src/sys/windows/process.rs index f4078d359448e..3b22f6d2e3158 100644 --- a/library/std/src/sys/windows/process.rs +++ b/library/std/src/sys/windows/process.rs @@ -597,7 +597,7 @@ impl Stdio { opts.read(stdio_id == c::STD_INPUT_HANDLE); opts.write(stdio_id != c::STD_INPUT_HANDLE); opts.security_attributes(&mut sa); - File::open(Path::new("NUL"), &opts).map(|file| file.into_inner()) + File::open(Path::new(r"\\.\NUL"), &opts).map(|file| file.into_inner()) } } }