[2/2] kernel32: DETACHED_PROCESS doesn't affect STARTUPINFO console handles.

Vincent Povirk madewokherd at gmail.com
Wed Jan 25 15:04:14 CST 2017


From: Vincent Povirk <vincent at codeweavers.com>

Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
 dlls/kernel32/process.c       |  2 +-
 dlls/kernel32/tests/process.c | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index aaa1058..5a9fea2 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -1711,7 +1711,7 @@ static startup_info_t *create_startup_info( LPCWSTR filename, LPCWSTR cmdline,
     info->hstdin  = wine_server_obj_handle( hstdin );
     info->hstdout = wine_server_obj_handle( hstdout );
     info->hstderr = wine_server_obj_handle( hstderr );
-    if ((flags & (CREATE_NEW_CONSOLE | DETACHED_PROCESS)) != 0)
+    if ((flags & CREATE_NEW_CONSOLE) != 0)
     {
         /* this is temporary (for console handles). We have no way to control that the handle is invalid in child process otherwise */
         if (is_console_handle(hstdin))  info->hstdin  = wine_server_obj_handle( INVALID_HANDLE_VALUE );
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index 9b429b8..f66ab45 100644
--- a/dlls/kernel32/tests/process.c
+++ b/dlls/kernel32/tests/process.c
@@ -2895,6 +2895,46 @@ static void test_StartupNoConsole(void)
 #endif
 }
 
+static void test_DetachConsoleHandles(void)
+{
+#ifndef _WIN64
+    char                buffer[MAX_PATH];
+    STARTUPINFOA        startup;
+    PROCESS_INFORMATION info;
+    UINT                result;
+
+    memset(&startup, 0, sizeof(startup));
+    startup.cb = sizeof(startup);
+    startup.dwFlags = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES;
+    startup.wShowWindow = SW_SHOWNORMAL;
+    startup.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
+    startup.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
+    startup.hStdError = GetStdHandle(STD_ERROR_HANDLE);
+    get_file_name(resfile);
+    sprintf(buffer, "\"%s\" tests/process.c dump \"%s\"", selfname, resfile);
+    ok(CreateProcessA(NULL, buffer, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &startup,
+                      &info), "CreateProcess\n");
+    ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n");
+    WritePrivateProfileStringA(NULL, NULL, NULL, resfile);
+
+    result = GetPrivateProfileIntA("StartupInfoA", "hStdInput", 0, resfile);
+    ok(result != 0 && result != (UINT)INVALID_HANDLE_VALUE, "bad handle %x\n", result);
+    result = GetPrivateProfileIntA("StartupInfoA", "hStdOutput", 0, resfile);
+    ok(result != 0 && result != (UINT)INVALID_HANDLE_VALUE, "bad handle %x\n", result);
+    result = GetPrivateProfileIntA("StartupInfoA", "hStdError", 0, resfile);
+    ok(result != 0 && result != (UINT)INVALID_HANDLE_VALUE, "bad handle %x\n", result);
+    result = GetPrivateProfileIntA("TEB", "hStdInput", 0, resfile);
+    ok(result != 0 && result != (UINT)INVALID_HANDLE_VALUE, "bad handle %x\n", result);
+    result = GetPrivateProfileIntA("TEB", "hStdOutput", 0, resfile);
+    ok(result != 0 && result != (UINT)INVALID_HANDLE_VALUE, "bad handle %x\n", result);
+    result = GetPrivateProfileIntA("TEB", "hStdError", 0, resfile);
+    ok(result != 0 && result != (UINT)INVALID_HANDLE_VALUE, "bad handle %x\n", result);
+
+    release_memory();
+    DeleteFileA(resfile);
+#endif
+}
+
 static void test_DetachStdHandles(void)
 {
 #ifndef _WIN64
@@ -3380,6 +3420,7 @@ START_TEST(process)
     test_RegistryQuota();
     test_DuplicateHandle();
     test_StartupNoConsole();
+    test_DetachConsoleHandles();
     test_DetachStdHandles();
     test_GetNumaProcessorNode();
     test_session_info();
-- 
2.7.4




More information about the wine-patches mailing list