Closed
Description
I tried this code:
use std::os::windows::process::CommandExt;
let mut res = std::process::Command::new(args.path)
// create a new console for child process
.creation_flags(0x00000010)
.current_dir(dirp)
.spawn()
.unwrap();
It works well on win10, the new process has an individual console for stdout & stderr, keyboard for stdin.
But the same binary can't get the same result on win7, the new process throw a IO.Exception.
I tried to delete a line in std/src/sys/windows/process.rs line: 258 fn spawn()
// si.dwFlags = c::STARTF_USESTDHANDLES;
Which let the windows to set a default stdio for new process.
In this case, the binary works well on both win7 & win10.
Meta
Both stable and nightly version of the compiler has the same situation.
rustc --version --verbose
:
rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: x86_64-pc-windows-msvc
release: 1.65.0
LLVM version: 15.0.0
rustc 1.67.0-nightly (c090c6880 2022-12-01)
binary: rustc
commit-hash: c090c6880c0183ba248bde4a16e29ba29ac4fbba
commit-date: 2022-12-01
host: x86_64-pc-windows-msvc
release: 1.67.0-nightly
LLVM version: 15.0.4
Backtrace
<backtrace>