about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-11-24 08:23:53 +0100
committerGitHub <noreply@github.com>2023-11-24 08:23:53 +0100
commitb2d6480f536196b8075d5fd451a70fca8f04a3f5 (patch)
treea9fa1d08423bdf40f977abceb3192fa0c8aab2ec
parentc3216e2a3a64b2505120487f19ceef4cc5e98e2e (diff)
parent3a486c1feb0a4846a3bcff0dda5182dc9c762ba2 (diff)
downloadrust-b2d6480f536196b8075d5fd451a70fca8f04a3f5.tar.gz
rust-b2d6480f536196b8075d5fd451a70fca8f04a3f5.zip
Rollup merge of #118060 - ChrisDenton:abs-device-path, r=thomcc
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.

r? libs
-rw-r--r--library/std/src/sys/windows/process.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/std/src/sys/windows/process.rs b/library/std/src/sys/windows/process.rs
index 51e16b9f13c..9ec775959fd 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())
             }
         }
     }