diff options
author | Brad King <brad.king@kitware.com> | 2024-01-24 15:27:20 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-01-24 21:59:49 (GMT) |
commit | adb3e13d323aeb19c3824112cfa712cc122db3b4 (patch) | |
tree | c17021aedf9c521d0540dc55cdbf07f3ade44e8f /Source/cmUVProcessChain.cxx | |
parent | b6e4e4babcdc6b44a1d494c4e9c07634c2b3bcd6 (diff) | |
download | CMake-adb3e13d323aeb19c3824112cfa712cc122db3b4.zip CMake-adb3e13d323aeb19c3824112cfa712cc122db3b4.tar.gz CMake-adb3e13d323aeb19c3824112cfa712cc122db3b4.tar.bz2 |
cmUVProcessChain: Tolerate fileno() of invalid FILE stream
On Windows, in a GUI process without a console, the `std{in,out,err}`
standard FILE streams may not be open. Avoid passing an invalid file
descriptor to the child process, and let libuv attach NUL instead.
Fixes: #25625
Diffstat (limited to 'Source/cmUVProcessChain.cxx')
-rw-r--r-- | Source/cmUVProcessChain.cxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Source/cmUVProcessChain.cxx b/Source/cmUVProcessChain.cxx index 338abba..cd452cb 100644 --- a/Source/cmUVProcessChain.cxx +++ b/Source/cmUVProcessChain.cxx @@ -122,7 +122,11 @@ cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetExternalStream( cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetExternalStream( Stream stdio, FILE* stream) { - return this->SetExternalStream(stdio, cm_fileno(stream)); + int fd = cm_fileno(stream); + if (fd >= 0) { + return this->SetExternalStream(stdio, fd); + } + return this->SetNoStream(stdio); } cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetMergedBuiltinStreams() |