summaryrefslogtreecommitdiffstats
path: root/Source/cmUVProcessChain.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-01-24 15:27:20 (GMT)
committerBrad King <brad.king@kitware.com>2024-01-24 21:59:49 (GMT)
commitadb3e13d323aeb19c3824112cfa712cc122db3b4 (patch)
treec17021aedf9c521d0540dc55cdbf07f3ade44e8f /Source/cmUVProcessChain.cxx
parentb6e4e4babcdc6b44a1d494c4e9c07634c2b3bcd6 (diff)
downloadCMake-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.cxx6
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()