[PATCH v2] testbot/TestLauncher: don't allocate a console when not attached to one

Eric Pouech eric.pouech at gmail.com
Wed Mar 30 10:55:55 CDT 2022


Fixing a Wine regression from f034084d49b354811096524d472ae5172ac1cebf.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Eric Pouech <eric.pouech at gmail.com>

V2: don't detach when attached to a console
---
 testbot/src/TestLauncher/TestLauncher.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/testbot/src/TestLauncher/TestLauncher.c b/testbot/src/TestLauncher/TestLauncher.c
index 41fb904..c30ee07 100644
--- a/testbot/src/TestLauncher/TestLauncher.c
+++ b/testbot/src/TestLauncher/TestLauncher.c
@@ -222,7 +222,7 @@ DWORD RunTest(char *TestExeFileName, char* CommandLine, DWORD TimeOut, DWORD *Pi
 {
    STARTUPINFOA StartupInfo;
    PROCESS_INFORMATION ProcessInformation;
-   DWORD ExitCode, WaitTimeOut;
+   DWORD ExitCode, WaitTimeOut, flags = CREATE_DEFAULT_ERROR_MODE;
 
    StartupInfo.cb = sizeof(STARTUPINFOA);
    GetStartupInfoA(&StartupInfo);
@@ -231,12 +231,14 @@ DWORD RunTest(char *TestExeFileName, char* CommandLine, DWORD TimeOut, DWORD *Pi
    StartupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
    StartupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
 
+   /* don't (potentially) create a console when not attached to one */
+   if (!GetConsoleCP()) flags |= DETACHED_PROCESS;
    /* Unlike WineTest we do not have the luxury of first running the test with
     * a --list argument. This means we cannot use SetErrorMode() to check
     * whether there are missing dependencies as it could modify the test
     * results...
     */
-   if (! CreateProcessA(NULL, CommandLine, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &StartupInfo, &ProcessInformation))
+   if (! CreateProcessA(NULL, CommandLine, NULL, NULL, TRUE, flags, NULL, NULL, &StartupInfo, &ProcessInformation))
    {
       *Pid = 0;
       if (GetLastError() == ERROR_SXS_CANT_GEN_ACTCTX)




More information about the wine-devel mailing list