Просмотр исходного кода

Merge topic 'execute_process-child-startup-info' into release-3.29

fa8c04b421 Tests/RunCMake/execute_process: Check STARTUPINFOW reserved members
d98df689ab Merge branch 'libuv-win-process-no-extra-stdio'
a590382850 libuv: win/spawn: disable extra-file-descriptor support not needed by CMake

Acked-by: Kitware Robot <[email protected]>
Merge-request: !9541
Brad King 1 год назад
Родитель
Сommit
522925206c

+ 4 - 0
Tests/RunCMake/CMakeLists.txt

@@ -513,6 +513,10 @@ set(execute_process_ARGS
 if(NOT CMake_TEST_EXTERNAL_CMAKE)
   list(APPEND execute_process_ARGS -DTEST_ENCODING_EXE=$<TARGET_FILE:testEncoding>)
 endif()
+if(WIN32)
+  add_executable(testStartupInfo testStartupInfo.c)
+  list(APPEND execute_process_ARGS -DTEST_STARTUPINFO_EXE=$<TARGET_FILE:testStartupInfo>)
+endif()
 add_RunCMake_test(execute_process)
 add_RunCMake_test(export)
 if(CMake_TEST_MSYSTEM_PREFIX)

+ 4 - 0
Tests/RunCMake/execute_process/RunCMakeTest.cmake

@@ -53,3 +53,7 @@ if(WIN32 OR CYGWIN)
   set(RunCMake_TEST_NO_CLEAN 1)
   run_cmake_command(WindowsNoExtension-build ${CMAKE_COMMAND} --build . --config Debug --target RunScript)
 endif()
+
+if(TEST_STARTUPINFO_EXE)
+  run_cmake_script(StartupInfo -DTEST_STARTUPINFO_EXE=${TEST_STARTUPINFO_EXE})
+endif()

+ 1 - 0
Tests/RunCMake/execute_process/StartupInfo.cmake

@@ -0,0 +1 @@
+execute_process(COMMAND "${TEST_STARTUPINFO_EXE}" COMMAND_ERROR_IS_FATAL ANY)

+ 25 - 0
Tests/RunCMake/testStartupInfo.c

@@ -0,0 +1,25 @@
+#ifndef _CRT_SECURE_NO_WARNINGS
+#  define _CRT_SECURE_NO_WARNINGS
+#endif
+
+#if defined(_MSC_VER) && _MSC_VER >= 1928
+#  pragma warning(disable : 5105) /* macro expansion warning in windows.h */
+#endif
+
+#include <windows.h>
+
+#include <stdio.h>
+#include <string.h>
+
+int main(void)
+{
+  STARTUPINFOW si;
+  memset(&si, 0, sizeof(si));
+  GetStartupInfoW(&si);
+  if (si.cbReserved2 != 0 || si.lpReserved2 != NULL) {
+    fprintf(stderr, "si.cbReserved2: %u\n", si.cbReserved2);
+    fprintf(stderr, "si.lpReserved2: %p\n", si.lpReserved2);
+    return 1;
+  }
+  return 0;
+}

+ 7 - 0
Utilities/cmlibuv/src/win/process.c

@@ -1083,8 +1083,15 @@ int uv_spawn(uv_loop_t* loop,
   startup.lpTitle = NULL;
   startup.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
 
+#if 1
+  /* cmake does not need libuv's support for passing file descriptors >= 3
+     to the MSVC C run-time in the child.  Avoid using reserved members.  */
+  startup.cbReserved2 = 0;
+  startup.lpReserved2 = NULL;
+#else
   startup.cbReserved2 = uv__stdio_size(process->child_stdio_buffer);
   startup.lpReserved2 = (BYTE*) process->child_stdio_buffer;
+#endif
 
   startup.hStdInput = uv__stdio_handle(process->child_stdio_buffer, 0);
   startup.hStdOutput = uv__stdio_handle(process->child_stdio_buffer, 1);