 
            -- v3: include: Pass a PROCESS_INFORMATION to winetest_wait_child_process().
 
            From: Elizabeth Figura zfigura@codeweavers.com
And close the handles in that function.
Most callers are simplified. Some callers need helpers to return the whole PROCESS_INFORMATION instead of just the process handle but are still simplified overall. In two cases the process handle is used after joining and so a WaitForSingleObject() is added. In one case, test_Toolhelp(), there is no PROCESS_INFORMATION and so the function is replaced.
This also avoids GetProcessId(), which does not exist on Windows 98. --- dlls/advapi32/tests/security.c | 8 +- dlls/dbgeng/tests/dbgeng.c | 12 +- dlls/gdi32/tests/font.c | 4 +- dlls/kernel32/tests/actctx.c | 9 +- dlls/kernel32/tests/console.c | 25 +--- dlls/kernel32/tests/heap.c | 7 +- dlls/kernel32/tests/pipe.c | 40 +++---- dlls/kernel32/tests/process.c | 130 +++++++++------------ dlls/kernel32/tests/toolhelp.c | 2 +- dlls/mfplat/tests/mfplat.c | 8 +- dlls/mscoree/tests/comtest.c | 9 +- dlls/mscoree/tests/mscoree.c | 4 +- dlls/msvcrt/tests/data.c | 2 +- dlls/msvcrt/tests/environ.c | 4 +- dlls/msvcrt/tests/file.c | 4 +- dlls/ntdll/tests/exception.c | 37 +----- dlls/ntdll/tests/info.c | 6 +- dlls/ole32/tests/marshal.c | 17 +-- dlls/oleacc/tests/main.c | 2 +- dlls/qmgr/tests/qmgr.c | 4 +- dlls/rpcrt4/tests/server.c | 23 ++-- dlls/shell32/tests/shellpath.c | 2 +- dlls/shlwapi/tests/ordinal.c | 4 +- dlls/sxs/tests/sxs.c | 6 +- dlls/ucrtbase/tests/environ.c | 4 +- dlls/ucrtbase/tests/misc.c | 4 +- dlls/uiautomationcore/tests/uiautomation.c | 2 +- dlls/urlmon/tests/misc.c | 4 +- dlls/urlmon/tests/sec_mgr.c | 4 +- dlls/user32/tests/class.c | 4 +- dlls/user32/tests/clipboard.c | 4 +- dlls/user32/tests/cursoricon.c | 3 +- dlls/user32/tests/input.c | 12 +- dlls/user32/tests/msg.c | 6 +- dlls/user32/tests/scroll.c | 8 +- dlls/user32/tests/win.c | 16 +-- dlls/user32/tests/winstation.c | 4 +- dlls/vulkan-1/tests/vulkan.c | 3 +- dlls/win32u/tests/win32u.c | 9 +- include/wine/test.h | 20 ++-- programs/conhost/tests/tty.c | 19 ++- 41 files changed, 167 insertions(+), 328 deletions(-)
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c index dba7955f2ea..b565526725f 100644 --- a/dlls/advapi32/tests/security.c +++ b/dlls/advapi32/tests/security.c @@ -3046,11 +3046,9 @@ static void test_process_security(void) STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL ); TEST_GRANTED_ACCESS2( info.hThread, THREAD_ALL_ACCESS_NT4, STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL ); - wait_child_process( info.hProcess ); + wait_child_process( &info );
FreeSid(EveryoneSid); - CloseHandle( info.hProcess ); - CloseHandle( info.hThread ); CloseHandle( event ); free(group); free(owner); @@ -7370,9 +7368,7 @@ static void test_token_security_descriptor(void) sprintf(buffer, "%s security test_token_sd", myARGV[0]); ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info); ok(ret, "CreateProcess failed with error %lu\n", GetLastError()); - wait_child_process(info.hProcess); - CloseHandle(info.hProcess); - CloseHandle(info.hThread); + wait_child_process(&info);
LocalFree(acl_child); free(sd2); diff --git a/dlls/dbgeng/tests/dbgeng.c b/dlls/dbgeng/tests/dbgeng.c index b0428215a9a..a75fa012b95 100644 --- a/dlls/dbgeng/tests/dbgeng.c +++ b/dlls/dbgeng/tests/dbgeng.c @@ -307,12 +307,7 @@ static void test_attach(void) ok(hr == S_OK, "Failed to end session, hr %#lx.\n", hr);
SetEvent(event); - - wait_child_process(info.hProcess); - - CloseHandle(info.hProcess); - CloseHandle(info.hThread); - + wait_child_process(&info); CloseHandle(event);
client->lpVtbl->Release(client); @@ -473,10 +468,7 @@ static void test_module_information(void) ok(hr == S_OK, "Failed to detach, hr %#lx.\n", hr);
SetEvent(event); - wait_child_process(info.hProcess); - - CloseHandle(info.hProcess); - CloseHandle(info.hThread); + wait_child_process(&info); CloseHandle(event);
client->lpVtbl->Release(client); diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index 933e061ce31..49c78e6894b 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -7999,8 +7999,6 @@ START_TEST(font) sprintf(path_name, "%s font %s", argv[0], test_names[i]); ok(CreateProcessA(NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info), "CreateProcess failed.\n"); - wait_child_process(info.hProcess); - CloseHandle(info.hProcess); - CloseHandle(info.hThread); + wait_child_process(&info); } } diff --git a/dlls/kernel32/tests/actctx.c b/dlls/kernel32/tests/actctx.c index 4d89484a3b1..fa67d37138c 100644 --- a/dlls/kernel32/tests/actctx.c +++ b/dlls/kernel32/tests/actctx.c @@ -2825,9 +2825,7 @@ static void run_child_process(void) sprintf(cmdline, ""%s" %s manifest1", argv[0], argv[1]); ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "Could not create process: %lu\n", GetLastError()); - wait_child_process( pi.hProcess ); - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); + wait_child_process( &pi ); DeleteFileA(path); }
@@ -4507,10 +4505,7 @@ static void run_child_process_two_dll(int run) ret = CreateProcessA(exe, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "Could not create process: %lu\n", GetLastError());
- wait_child_process( pi.hProcess ); - - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); + wait_child_process( &pi ); }
static const detailed_info_t detailed_info3 = diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 02c34a3aa3b..35ea04a2d5f 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -4622,17 +4622,13 @@ static void test_GetConsoleOriginalTitle(void) si.lpTitle = title; ret = CreateProcessA(NULL, buf, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &info); ok(ret, "CreateProcess failed: %lu\n", GetLastError()); - CloseHandle(info.hThread); - wait_child_process(info.hProcess); - CloseHandle(info.hProcess); + wait_child_process(&info);
strcat(buf, " empty"); title[0] = 0; ret = CreateProcessA(NULL, buf, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &info); ok(ret, "CreateProcess failed: %lu\n", GetLastError()); - CloseHandle(info.hThread); - wait_child_process(info.hProcess); - CloseHandle(info.hProcess); + wait_child_process(&info); }
static void test_GetConsoleTitleA(void) @@ -4907,10 +4903,7 @@ static void test_AttachConsole(HANDLE console) sprintf(buf, ""%s" console attach_console %lx", argv[0], GetCurrentProcessId()); res = CreateProcessA(NULL, buf, NULL, NULL, TRUE, 0, NULL, NULL, &si, &info); ok(res, "CreateProcess failed: %lu\n", GetLastError()); - CloseHandle(info.hThread); - - wait_child_process(info.hProcess); - CloseHandle(info.hProcess); + wait_child_process(&info);
res = ReadConsoleOutputCharacterA(console, buf, 5, c, &len); ok(res, "ReadConsoleOutputCharacterA failed: %lu\n", GetLastError()); @@ -5003,9 +4996,7 @@ static void test_AllocConsole(void) sprintf(buf, ""%s" console alloc_console", argv[0]); res = CreateProcessA(NULL, buf, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &info); ok(res, "CreateProcess failed: %lu\n", GetLastError()); - CloseHandle(info.hThread); - wait_child_process(info.hProcess); - CloseHandle(info.hProcess); + wait_child_process(&info);
res = CreatePipe(&pipe_read, &pipe_write, &inheritable_attr, 0); ok(res, "CreatePipe failed: %lu\n", GetLastError()); @@ -5014,9 +5005,7 @@ static void test_AllocConsole(void) si.hStdError = pipe_write; res = CreateProcessA(NULL, buf, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &info); ok(res, "CreateProcess failed: %lu\n", GetLastError()); - CloseHandle(info.hThread); - wait_child_process(info.hProcess); - CloseHandle(info.hProcess); + wait_child_process(&info);
CloseHandle(pipe_read); CloseHandle(pipe_write); @@ -5155,10 +5144,8 @@ static void test_pseudo_console(void) ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL, &startup.StartupInfo, &info); ok(ret, "CreateProcessW failed: %lu\n", GetLastError());
- CloseHandle(info.hThread); HeapFree(GetProcessHeap(), 0, startup.lpAttributeList); - wait_child_process(info.hProcess); - CloseHandle(info.hProcess); + wait_child_process(&info);
pClosePseudoConsole(pseudo_console); } diff --git a/dlls/kernel32/tests/heap.c b/dlls/kernel32/tests/heap.c index 5d43851baa6..1d4c1c8bf6e 100644 --- a/dlls/kernel32/tests/heap.c +++ b/dlls/kernel32/tests/heap.c @@ -3400,12 +3400,7 @@ static void test_debug_heap( const char *argv0, DWORD flags ) sprintf( buffer, "%s heap.c 0x%lx", argv0, flags ); ret = CreateProcessA( NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info ); ok( ret, "failed to create child process error %lu\n", GetLastError() ); - if (ret) - { - wait_child_process( info.hProcess ); - CloseHandle( info.hThread ); - CloseHandle( info.hProcess ); - } + wait_child_process( &info ); RegDeleteValueA( hkey, "GlobalFlag" ); RegCloseKey( hkey ); RegDeleteKeyA( HKEY_LOCAL_MACHINE, keyname ); diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c index aff65fe2864..ffdd4d00273 100644 --- a/dlls/kernel32/tests/pipe.c +++ b/dlls/kernel32/tests/pipe.c @@ -3181,20 +3181,16 @@ static void child_process_write_pipe(HANDLE pipe) Sleep(INFINITE); }
-static HANDLE create_writepipe_process(HANDLE pipe) +static void create_writepipe_process(HANDLE pipe, PROCESS_INFORMATION *info) { STARTUPINFOA si = { sizeof(si) }; - PROCESS_INFORMATION info; char **argv, buf[MAX_PATH]; BOOL res;
winetest_get_mainargs(&argv); sprintf(buf, ""%s" pipe writepipe %Ix", argv[0], (UINT_PTR)pipe); - res = CreateProcessA(NULL, buf, NULL, NULL, TRUE, 0L, NULL, NULL, &si, &info); + res = CreateProcessA(NULL, buf, NULL, NULL, TRUE, 0L, NULL, NULL, &si, info); ok(res, "CreateProcess failed: %lu\n", GetLastError()); - CloseHandle(info.hThread); - - return info.hProcess; }
static void create_overlapped_pipe(DWORD mode, HANDLE *client, HANDLE *server) @@ -3230,9 +3226,9 @@ static void create_overlapped_pipe(DWORD mode, HANDLE *client, HANDLE *server) static void test_overlapped_transport(BOOL msg_mode, BOOL msg_read_mode) { OVERLAPPED overlapped, overlapped2; + PROCESS_INFORMATION process_info; HANDLE server, client, flush; DWORD read_bytes; - HANDLE process; char buf[60000]; BOOL res;
@@ -3286,7 +3282,7 @@ static void test_overlapped_transport(BOOL msg_mode, BOOL msg_read_mode)
/* terminate process with pending write */ create_overlapped_pipe(create_flags, &client, &server); - process = create_writepipe_process(client); + create_writepipe_process(client, &process_info); /* successfully read part of write that is pending in child process */ res = ReadFile(server, buf, 10, &read_bytes, NULL); if(!msg_read_mode) @@ -3294,13 +3290,12 @@ static void test_overlapped_transport(BOOL msg_mode, BOOL msg_read_mode) else ok(!res && GetLastError() == ERROR_MORE_DATA, "ReadFile returned: %x %lu\n", res, GetLastError()); ok(read_bytes == 10, "read_bytes = %lu\n", read_bytes); - TerminateProcess(process, 0); - wait_child_process(process); + TerminateProcess(process_info.hProcess, 0); + wait_child_process(&process_info); /* after terminating process, there is no pending write and pipe buffer is empty */ overlapped_read_async(server, buf, 10, &overlapped); overlapped_write_sync(client, buf, 1); test_overlapped_result(server, &overlapped, 1, FALSE); - CloseHandle(process); CloseHandle(server); CloseHandle(client); } @@ -3439,24 +3434,22 @@ static void child_process_check_pid(DWORD server_pid) CloseHandle(pipe); }
-static HANDLE create_check_id_process(const char *verb, DWORD id) +static void create_check_id_process(const char *verb, DWORD id, PROCESS_INFORMATION *info) { STARTUPINFOA si = {sizeof(si)}; - PROCESS_INFORMATION info; char **argv, buf[MAX_PATH]; BOOL ret;
winetest_get_mainargs(&argv); sprintf(buf, ""%s" pipe %s %lx", argv[0], verb, id); - ret = CreateProcessA(NULL, buf, NULL, NULL, TRUE, 0, NULL, NULL, &si, &info); + ret = CreateProcessA(NULL, buf, NULL, NULL, TRUE, 0, NULL, NULL, &si, info); ok(ret, "got %lu\n", GetLastError()); - CloseHandle(info.hThread); - return info.hProcess; }
static void test_namedpipe_process_id(void) { - HANDLE client, server, process; + PROCESS_INFORMATION process_info; + HANDLE client, server; DWORD current = GetProcessId(GetCurrentProcess()); OVERLAPPED overlapped; ULONG pid; @@ -3560,11 +3553,10 @@ static void test_namedpipe_process_id(void) server = create_overlapped_server( &overlapped ); ok(server != INVALID_HANDLE_VALUE, "got %lu\n", GetLastError());
- process = create_check_id_process("checkpid", GetProcessId(GetCurrentProcess())); - wait_child_process(process); + create_check_id_process("checkpid", GetProcessId(GetCurrentProcess()), &process_info); + wait_child_process(&process_info);
CloseHandle(overlapped.hEvent); - CloseHandle(process); CloseHandle(server); }
@@ -3594,7 +3586,8 @@ static void child_process_check_session_id(DWORD server_id)
static void test_namedpipe_session_id(void) { - HANDLE client, server, process; + PROCESS_INFORMATION process_info; + HANDLE client, server; OVERLAPPED overlapped; DWORD current; ULONG id; @@ -3703,11 +3696,10 @@ static void test_namedpipe_session_id(void) server = create_overlapped_server( &overlapped ); ok(server != INVALID_HANDLE_VALUE, "got %lu\n", GetLastError());
- process = create_check_id_process("checksessionid", current); - wait_child_process(process); + create_check_id_process("checksessionid", current, &process_info); + wait_child_process(&process_info);
CloseHandle(overlapped.hEvent); - CloseHandle(process); CloseHandle(server); }
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index f539f69b3af..9dd6aaa626e 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -208,13 +208,6 @@ static WCHAR* decodeW(const char* str) return ptr; }
-static void wait_and_close_child_process(PROCESS_INFORMATION *pi) -{ - wait_child_process(pi->hProcess); - CloseHandle(pi->hThread); - CloseHandle(pi->hProcess); -} - static void reload_child_info(const char* resfile) { /* This forces the profile functions to reload the resource file @@ -679,7 +672,7 @@ static void test_Startup(void) get_file_name(resfile); sprintf(buffer, ""%s" process dump "%s"", selfname, resfile); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); GetStartupInfoA(&si); @@ -715,7 +708,7 @@ static void test_Startup(void) get_file_name(resfile); sprintf(buffer, ""%s" process dump "%s"", selfname, resfile); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); okChildInt("StartupInfoA", "cb", startup.cb); @@ -751,7 +744,7 @@ static void test_Startup(void) get_file_name(resfile); sprintf(buffer, ""%s" process dump "%s"", selfname, resfile); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); okChildInt("StartupInfoA", "cb", startup.cb); @@ -787,7 +780,7 @@ static void test_Startup(void) get_file_name(resfile); sprintf(buffer, ""%s" process dump "%s"", selfname, resfile); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); okChildInt("StartupInfoA", "cb", startup.cb); @@ -823,7 +816,7 @@ static void test_Startup(void) get_file_name(resfile); sprintf(buffer, ""%s" process dump "%s"", selfname, resfile); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); okChildInt("StartupInfoA", "cb", startup.cb); @@ -861,7 +854,7 @@ static void test_Startup(void) get_file_name(resfile); sprintf(buffer, ""%s" process dump "%s"", selfname, resfile); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); okChildInt("StartupInfoA", "cb", startup.cb); @@ -897,7 +890,7 @@ static void test_Startup(void) get_file_name(resfile); sprintf(buffer, ""%s" process dump "%s"", selfname, resfile); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); okChildInt("StartupInfoA", "cb", startup.cb); @@ -957,7 +950,7 @@ static void test_CommandLine(void) ok(startup.lpTitle == NULL, "lpTitle is not NULL\n"); ok(startup.dwFlags == STARTF_USESHOWWINDOW, "unexpected dwFlags %04lx\n", startup.dwFlags); ok(startup.wShowWindow == SW_SHOWNORMAL, "unexpected wShowWindow %d\n", startup.wShowWindow); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); okChildInt("Arguments", "argcA", 5); @@ -971,7 +964,7 @@ static void test_CommandLine(void) get_file_name(resfile); sprintf(buffer, ""%s" process dump "%s" "a\"b\\" c\" d", selfname, resfile); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); okChildInt("Arguments", "argcA", 7); @@ -997,7 +990,7 @@ static void test_CommandLine(void) SetLastError(0xdeadbeef); ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info); ok(ret, "CreateProcess (%s) failed : %ld\n", buffer, GetLastError()); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); sprintf(buffer, "./%s", exename); @@ -1014,7 +1007,7 @@ static void test_CommandLine(void) SetLastError(0xdeadbeef); ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info); ok(ret, "CreateProcess (%s) failed : %ld\n", buffer, GetLastError()); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); sprintf(buffer, ".\%s", exename); @@ -1030,7 +1023,7 @@ static void test_CommandLine(void) SetLastError(0xdeadbeef); ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info); ok(ret, "CreateProcess (%s) failed : %ld\n", buffer, GetLastError()); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); if (p) sprintf(buffer, "..%s/%s", p, exename); @@ -1052,7 +1045,7 @@ static void test_CommandLine(void) SetLastError(0xdeadbeef); ret = CreateProcessA(buffer, buffer2, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info); ok(ret, "CreateProcess (%s) failed : %ld\n", buffer, GetLastError()); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); okChildString("Arguments", "argvA0", "dummy"); @@ -1158,7 +1151,7 @@ static void test_Directory(void) sprintf(buffer, ""%s" process dump "%s"", selfname, resfile); GetWindowsDirectoryA( windir, sizeof(windir) ); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, windir, &startup, &info), "CreateProcess\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); okChildIString("Misc", "CurrDirA", windir); @@ -1186,11 +1179,10 @@ static void test_Toolhelp(void) STARTUPINFOA startup; PROCESS_INFORMATION info; HANDLE process, thread, snapshot; - DWORD nested_pid; PROCESSENTRY32 pe; THREADENTRY32 te; - DWORD ret; int i; + DWORD ret, nested_pid, exit_code;
memset(&startup, 0, sizeof(startup)); startup.cb = sizeof(startup); @@ -1200,7 +1192,7 @@ static void test_Toolhelp(void) get_file_name(resfile); sprintf(buffer, ""%s" process dump "%s"", selfname, resfile); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess failed\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); okChildInt("Toolhelp", "cntUsage", 0); @@ -1216,7 +1208,7 @@ static void test_Toolhelp(void) get_file_name(resfile); sprintf(buffer, ""%s" process nested "%s"", selfname, resfile); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess failed\n"); - wait_child_process(info.hProcess); + wait_child_process(&info);
process = OpenProcess(PROCESS_ALL_ACCESS_NT4, FALSE, info.dwProcessId); ok(process != NULL, "OpenProcess failed %lu\n", GetLastError()); @@ -1277,6 +1269,11 @@ static void test_Toolhelp(void) ok(ret == 1, "expected 1, got %lu\n", ret); CloseHandle(thread);
+ ret = WaitForSingleObject(process, 30000); + ok(!ret, "got %ld\n", ret); + ret = GetExitCodeProcess(process, &exit_code); + ok(!exit_code, "got exit code %#lx\n", exit_code); + wait_child_process(process); CloseHandle(process);
@@ -1376,7 +1373,7 @@ static void test_Environment(void) get_file_name(resfile); sprintf(buffer, ""%s" process dump "%s"", selfname, resfile); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); env = GetEnvironmentStringsA(); @@ -1429,7 +1426,7 @@ static void test_Environment(void) } *ptr = '\0'; ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, child_env, NULL, &startup, &info), "CreateProcess\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); cmpEnvironment(child_env); @@ -1463,7 +1460,7 @@ static void test_SuspendFlag(void) ok(GetExitCodeThread(info.hThread, &exit_status) && exit_status == STILL_ACTIVE, "thread still running\n"); ok(ResumeThread(info.hThread) == 1, "Resuming thread\n");
- wait_and_close_child_process(&info); + wait_child_process(&info);
GetStartupInfoA(&us);
@@ -1523,7 +1520,7 @@ static void test_DebuggingFlag(void) } while (de.dwDebugEventCode != EXIT_PROCESS_DEBUG_EVENT);
ok(dbg, "I have seen a debug event\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
GetStartupInfoA(&us);
@@ -1601,7 +1598,7 @@ static void test_Console(void) get_file_name(resfile); sprintf(buffer, ""%s" process dump "%s" console", selfname, resfile); ok(CreateProcessA(NULL, buffer, NULL, NULL, TRUE, 0, NULL, NULL, &startup, &info), "CreateProcess\n"); - wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); /* now get the modification the child has made, and resets parents expected values */ @@ -1727,7 +1724,7 @@ static void test_Console(void) /* the child may also send the final "n tests executed" string, so read it to avoid a deadlock */ ReadFile(hParentIn, buffer, sizeof(buffer), &w, NULL);
- wait_and_close_child_process(&info); + wait_child_process(&info);
reload_child_info(resfile); okChildString("StdHandle", "msg", msg); @@ -2825,7 +2822,7 @@ static void test_QueryInformationJobObject(void) ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
ReleaseSemaphore(sem, 1, NULL); - wait_and_close_child_process(&pi[0]); + wait_child_process(&pi[0]);
create_process("wait", &pi[0]); ret = pAssignProcessToJobObject(job, pi[0].hProcess); @@ -3113,7 +3110,7 @@ static void test_WaitForJobObject(void) dwret = WaitForSingleObject(job, 100); ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %lu\n", dwret);
- wait_and_close_child_process(&pi); + wait_child_process(&pi); CloseHandle(job); CloseHandle(sem); } @@ -3154,7 +3151,7 @@ static void test_jobInheritance(HANDLE job) test_assigned_proc(job, 2, GetCurrentProcessId(), pi.dwProcessId); test_accounting(job, 2, 2, 0);
- wait_and_close_child_process(&pi); + wait_child_process(&pi); }
static void test_BreakawayOk(HANDLE parent_job) @@ -3190,7 +3187,7 @@ static void test_BreakawayOk(HANDLE parent_job) if (ret) { TerminateProcess(pi.hProcess, 0); - wait_and_close_child_process(&pi); + wait_child_process(&pi); }
if (nested_jobs) @@ -3215,7 +3212,7 @@ static void test_BreakawayOk(HANDLE parent_job) ok(out, "IsProcessInJob returned out=%u\n", out);
TerminateProcess(pi.hProcess, 0); - wait_and_close_child_process(&pi); + wait_child_process(&pi); }
limit_info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_BREAKAWAY_OK; @@ -3238,7 +3235,7 @@ static void test_BreakawayOk(HANDLE parent_job) ok(ret, "IsProcessInJob error %lu\n", GetLastError()); ok(!out, "IsProcessInJob returned out=%u\n", out);
- wait_and_close_child_process(&pi); + wait_child_process(&pi);
limit_info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK; ret = pSetInformationJobObject(job, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info)); @@ -3256,7 +3253,7 @@ static void test_BreakawayOk(HANDLE parent_job) test_accounting(job, 1, 1, 0); }
- wait_and_close_child_process(&pi); + wait_child_process(&pi);
/* unset breakaway ok */ limit_info.BasicLimitInformation.LimitFlags = 0; @@ -3783,7 +3780,7 @@ static void test_SuspendProcessNewThread(void) * is set by the TerminateProcess() call. */ TerminateProcess(pi.hProcess, 0); - wait_and_close_child_process(&pi); + wait_child_process(&pi); }
static void test_SuspendProcessState(void) @@ -4582,7 +4579,7 @@ static void test_parent_process_attribute(unsigned int level, HANDLE read_pipe) ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL, (STARTUPINFOA *)&si, &info); ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); - wait_and_close_child_process(&info); + wait_child_process(&info); #endif si.lpAttributeList = heap_alloc(size); ret = pInitializeProcThreadAttributeList(si.lpAttributeList, 1, 0, &size); @@ -4594,7 +4591,7 @@ static void test_parent_process_attribute(unsigned int level, HANDLE read_pipe) ret = CreateProcessA(NULL, buffer, NULL, NULL, TRUE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL, (STARTUPINFOA *)&si, &info); ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError()); - wait_and_close_child_process(&info); + wait_child_process(&info); CloseHandle(handle); pDeleteProcThreadAttributeList(si.lpAttributeList); heap_free(si.lpAttributeList); @@ -4640,7 +4637,7 @@ static void test_parent_process_attribute(unsigned int level, HANDLE read_pipe) ok(ret || broken(!ret && GetLastError() == ERROR_INVALID_HANDLE), "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError()); if (ret) - wait_and_close_child_process(&info); + wait_child_process(&info); pDeleteProcThreadAttributeList(si.lpAttributeList); heap_free(si.lpAttributeList);
@@ -4671,7 +4668,7 @@ static void test_parent_process_attribute(unsigned int level, HANDLE read_pipe) ret = WriteFile(write_pipe, &parent_data, sizeof(parent_data), &size, NULL); }
- wait_and_close_child_process(&info); + wait_child_process(&info);
if (!level) { @@ -4743,7 +4740,7 @@ static void test_handle_list_attribute(BOOL child, HANDLE handle1, HANDLE handle (STARTUPINFOA *)&si, &info); ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError());
- wait_and_close_child_process(&info); + wait_child_process(&info);
CloseHandle(pipe[0]); CloseHandle(pipe[1]); @@ -4764,7 +4761,9 @@ static void test_dead_process(void) NTSTATUS status;
create_process("exit", &pi); - wait_child_process(pi.hProcess); + + status = WaitForSingleObject( pi.hProcess, 30000 ); + ok( !status, "got %ld\n", status ); Sleep(100);
memset( data, 0, sizeof(data) ); @@ -4806,8 +4805,8 @@ static void test_dead_process(void) offset += spi->NextEntryOffset; } while (spi->NextEntryOffset); ok( !found, "process still enumerated\n" ); - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); + + wait_child_process( &pi ); }
static void test_nested_jobs_child(unsigned int index) @@ -4885,9 +4884,7 @@ static void test_nested_jobs_child(unsigned int index) ok(ret, "AssignProcessToJobObject error %lu\n", GetLastError());
TerminateProcess(pi.hProcess, 0); - wait_child_process(pi.hProcess); - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); + wait_child_process(&pi);
dead_pid = pi.dwProcessId;
@@ -4952,10 +4949,8 @@ static void test_nested_jobs_child(unsigned int index)
done: TerminateProcess(pi.hProcess, 0); - wait_child_process(pi.hProcess); + wait_child_process(&pi);
- CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); CloseHandle(job_parent); CloseHandle(job); CloseHandle(job_other); @@ -5012,9 +5007,7 @@ static void test_nested_jobs(void) ok(GetLastError() == ERROR_ACCESS_DENIED, "Got unexpected error %lu.\n", GetLastError());
TerminateProcess(info[1].hProcess, 0); - wait_child_process(info[1].hProcess); - CloseHandle(info[1].hProcess); - CloseHandle(info[1].hThread); + wait_child_process(&info[1]);
ret = pAssignProcessToJobObject(job2, info[0].hProcess); ok(!ret, "AssignProcessToJobObject succeeded\n"); @@ -5022,9 +5015,7 @@ static void test_nested_jobs(void) }
TerminateProcess(info[0].hProcess, 0); - wait_child_process(info[0].hProcess); - CloseHandle(info[0].hProcess); - CloseHandle(info[0].hThread); + wait_child_process(&info[0]); }
if (already_in_job) @@ -5043,16 +5034,11 @@ static void test_nested_jobs(void) sprintf(buffer, ""%s" process nested_jobs 0", selfname); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &info[0]), "CreateProcess failed\n"); - wait_child_process(info[0].hProcess); + wait_child_process(&info[0]); sprintf(buffer, ""%s" process nested_jobs 1", selfname); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &info[1]), "CreateProcess failed\n"); - wait_child_process(info[1].hProcess); - for (i = 0; i < 2; ++i) - { - CloseHandle(info[i].hProcess); - CloseHandle(info[i].hThread); - } + wait_child_process(&info[1]);
CloseHandle(job1); CloseHandle(job2); @@ -5154,7 +5140,7 @@ static void test_job_list_attribute(HANDLE parent_job) ok(out, "IsProcessInJob returned out=%u\n", out);
TerminateProcess(pi.hProcess, 0); - wait_and_close_child_process(&pi); + wait_child_process(&pi);
jobs[0] = pCreateJobObjectW(NULL, NULL); ok(!!jobs[0], "CreateJobObjectA error %lu\n", GetLastError()); @@ -5191,7 +5177,7 @@ static void test_job_list_attribute(HANDLE parent_job) ok(!out, "IsProcessInJob returned out=%u\n", out);
TerminateProcess(pi.hProcess, 0); - wait_and_close_child_process(&pi); + wait_child_process(&pi);
CloseHandle(jobs[1]); jobs[1] = pCreateJobObjectW(NULL, NULL); @@ -5218,7 +5204,7 @@ static void test_job_list_attribute(HANDLE parent_job) ok(!out, "IsProcessInJob returned out=%u\n", out);
TerminateProcess(pi.hProcess, 0); - wait_and_close_child_process(&pi); + wait_child_process(&pi);
ret = pQueryInformationJobObject(jobs[0], JobObjectBasicAccountingInformation, &job_info, sizeof(job_info), NULL); @@ -5309,7 +5295,7 @@ static void test_job_list_attribute(HANDLE parent_job) ok(out, "IsProcessInJob returned out=%u\n", out);
TerminateProcess(pi.hProcess, 0); - wait_and_close_child_process(&pi); + wait_child_process(&pi);
tmp = jobs[0]; jobs[0] = jobs[1]; @@ -5354,7 +5340,7 @@ static void test_job_list_attribute(HANDLE parent_job) ok(out, "IsProcessInJob returned out=%u\n", out);
TerminateProcess(pi.hProcess, 0); - wait_and_close_child_process(&pi); + wait_child_process(&pi);
ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size); ok(ret, "Got unexpected ret %#x, GetLastError() %lu.\n", ret, GetLastError()); @@ -5377,7 +5363,7 @@ static void test_job_list_attribute(HANDLE parent_job) ok(out, "IsProcessInJob returned out=%u\n", out);
TerminateProcess(pi.hProcess, 0); - wait_and_close_child_process(&pi); + wait_child_process(&pi);
CloseHandle(jobs[0]); CloseHandle(jobs[1]); diff --git a/dlls/kernel32/tests/toolhelp.c b/dlls/kernel32/tests/toolhelp.c index 7fdf597d3a6..02ec0a30b81 100644 --- a/dlls/kernel32/tests/toolhelp.c +++ b/dlls/kernel32/tests/toolhelp.c @@ -505,5 +505,5 @@ START_TEST(toolhelp) test_module(info.dwProcessId, sub_expected_modules, ARRAY_SIZE(sub_expected_modules));
SetEvent(ev2); - wait_child_process( info.hProcess ); + wait_child_process( &info ); } diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index 21bcc86c8d1..153b0da132d 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -7185,9 +7185,7 @@ static void test_queue_com(void) sprintf(path_name, "%s mfplat s%d", argv[0], system_queues[i]); ok(CreateProcessA( NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info), "CreateProcess failed.\n" ); - wait_child_process(info.hProcess); - CloseHandle(info.hProcess); - CloseHandle(info.hThread); + wait_child_process(&info); }
for (i = 0; i < ARRAY_SIZE(user_queues); ++i) @@ -7197,9 +7195,7 @@ static void test_queue_com(void) sprintf(path_name, "%s mfplat u%d", argv[0], user_queues[i]); ok(CreateProcessA( NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info), "CreateProcess failed.\n" ); - wait_child_process(info.hProcess); - CloseHandle(info.hProcess); - CloseHandle(info.hThread); + wait_child_process(&info); } }
diff --git a/dlls/mscoree/tests/comtest.c b/dlls/mscoree/tests/comtest.c index ead76321d0c..310e0cd9618 100644 --- a/dlls/mscoree/tests/comtest.c +++ b/dlls/mscoree/tests/comtest.c @@ -94,9 +94,7 @@ static BOOL compile_cs_to_dll(char *source_path, char *dest_path) ret = CreateProcessA(path_csc, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "Could not create process: %lu\n", GetLastError());
- wait_child_process(pi.hProcess); - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); + wait_child_process(&pi);
ret = PathFileExistsA(path_temp); ok(ret, "Compilation failed\n"); @@ -374,10 +372,7 @@ static void run_child_process(const char *dll_source, run_type run) ret = CreateProcessA(exe, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "Could not create process: %lu\n", GetLastError());
- wait_child_process(pi.hProcess); - - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); + wait_child_process(&pi);
/* Cleanup dll, because it might still have been used by the child */ cleanup_test(run); diff --git a/dlls/mscoree/tests/mscoree.c b/dlls/mscoree/tests/mscoree.c index 36594972866..24ba698b3ff 100644 --- a/dlls/mscoree/tests/mscoree.c +++ b/dlls/mscoree/tests/mscoree.c @@ -582,9 +582,7 @@ static BOOL compile_cs(const WCHAR *source, const WCHAR *target, const WCHAR *ty ret = CreateProcessW(csc, cmdline, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi); ok(ret, "Could not create process: %lu\n", GetLastError());
- wait_child_process(pi.hProcess); - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); + wait_child_process(&pi);
ret = PathFileExistsW(target); ok(ret, "Compilation failed\n"); diff --git a/dlls/msvcrt/tests/data.c b/dlls/msvcrt/tests/data.c index a0de94fd352..722af511517 100644 --- a/dlls/msvcrt/tests/data.c +++ b/dlls/msvcrt/tests/data.c @@ -217,7 +217,7 @@ static void test___getmainargs_parent(char *name) memset(&startup, 0, sizeof(startup)); startup.cb = sizeof(startup); CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE|NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, &proc); - wait_child_process(proc.hProcess); + wait_child_process(&proc);
_unlink(filepath); sprintf(filepath, "%swine_test\a", tmppath); diff --git a/dlls/msvcrt/tests/environ.c b/dlls/msvcrt/tests/environ.c index 1d1bfd2f504..b6a2d7bf830 100644 --- a/dlls/msvcrt/tests/environ.c +++ b/dlls/msvcrt/tests/environ.c @@ -415,9 +415,7 @@ static void test_child_env(char** argv) snprintf( tmp, sizeof(tmp), "%s %s create", argv[0], argv[1] ); ret = CreateProcessA( NULL, tmp, NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT, env, NULL, &si, &pi ); ok( ret, "Couldn't create child process %s\n", tmp ); - winetest_wait_child_process( pi.hProcess ); - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); + winetest_wait_child_process( &pi ); free( env ); }
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index 6ead01e9e2d..1cd3a5bffde 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -1722,7 +1722,7 @@ static void test_stdout_handle( STARTUPINFOA *startup, char *cmdline, HANDLE hst
CreateProcessA( NULL, cmdline, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE | NORMAL_PRIORITY_CLASS, NULL, NULL, startup, &proc ); - wait_child_process( proc.hProcess ); + wait_child_process( &proc );
data = read_file( hErrorFile ); if (expect_stdout) @@ -2002,7 +2002,7 @@ static void test_invalid_stdin( const char* selfname ) sprintf(cmdline, "%s file stdin", selfname); CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE|NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, &proc); - wait_child_process(proc.hProcess); + wait_child_process(&proc);
ret = RegCloseKey(key); ok(!ret, "RegCloseKey failed: %lx\n", ret); diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 122cd592238..82cc6cde846 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -1548,13 +1548,7 @@ static void test_debugger(DWORD cont_status, BOOL with_WaitForDebugEventEx)
} while (de.dwDebugEventCode != EXIT_PROCESS_DEBUG_EVENT);
- wait_child_process( pi.hProcess ); - ret = CloseHandle(pi.hThread); - ok(ret, "error %lu\n", GetLastError()); - ret = CloseHandle(pi.hProcess); - ok(ret, "error %lu\n", GetLastError()); - - return; + wait_child_process( &pi ); }
static DWORD simd_fault_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD *frame, @@ -4136,11 +4130,7 @@ static void test_debugger(DWORD cont_status, BOOL with_WaitForDebugEventEx)
} while (de.dwDebugEventCode != EXIT_PROCESS_DEBUG_EVENT);
- wait_child_process( pi.hProcess ); - ret = CloseHandle(pi.hThread); - ok(ret, "error %lu\n", GetLastError()); - ret = CloseHandle(pi.hProcess); - ok(ret, "error %lu\n", GetLastError()); + wait_child_process( &pi ); }
static void test_thread_context(void) @@ -6643,11 +6633,7 @@ static void test_debugger(DWORD cont_status, BOOL with_WaitForDebugEventEx)
} while (de.dwDebugEventCode != EXIT_PROCESS_DEBUG_EVENT);
- wait_child_process( pi.hProcess ); - ret = CloseHandle(pi.hThread); - ok(ret, "error %lu\n", GetLastError()); - ret = CloseHandle(pi.hProcess); - ok(ret, "error %lu\n", GetLastError()); + wait_child_process( &pi ); }
static void test_debug_service(DWORD numexc) @@ -7810,11 +7796,7 @@ static void test_debugger(DWORD cont_status, BOOL with_WaitForDebugEventEx)
} while (de.dwDebugEventCode != EXIT_PROCESS_DEBUG_EVENT);
- wait_child_process( pi.hProcess ); - ret = CloseHandle(pi.hThread); - ok(ret, "error %lu\n", GetLastError()); - ret = CloseHandle(pi.hProcess); - ok(ret, "error %lu\n", GetLastError()); + wait_child_process( &pi ); }
static void test_debug_service(DWORD numexc) @@ -9494,11 +9476,7 @@ static void subtest_fastfail(unsigned int code)
ok(had_ff || broken(had_se) /* Win7 */, "fast fail did not occur\n");
- wait_child_process( pi.hProcess ); - ret = CloseHandle(pi.hThread); - ok(ret, "error %lu\n", GetLastError()); - ret = CloseHandle(pi.hProcess); - ok(ret, "error %lu\n", GetLastError()); + wait_child_process( &pi );
return; } @@ -10105,10 +10083,7 @@ static void test_suspend_process(void)
SetEvent(event);
- wait_child_process(info.hProcess); - - CloseHandle(info.hProcess); - CloseHandle(info.hThread); + wait_child_process( &info );
CloseHandle(event); CloseHandle(event2); diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index a32513fd54b..67b0b4c3506 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -2194,11 +2194,7 @@ static void subtest_query_process_debug_port_custom_dacl(int argc, char **argv, if (!ret) break; } while (ev.dwDebugEventCode != EXIT_PROCESS_DEBUG_EVENT);
- wait_child_process(pi.hProcess); - ret = CloseHandle(pi.hThread); - ok(ret, "CloseHandle failed, last error %#lx.\n", GetLastError()); - ret = CloseHandle(pi.hProcess); - ok(ret, "CloseHandle failed, last error %#lx.\n", GetLastError()); + wait_child_process( &pi );
close_debug_obj: pDbgUiSetThreadDebugObject(old_debug_obj); diff --git a/dlls/ole32/tests/marshal.c b/dlls/ole32/tests/marshal.c index 5848e9a519a..0e13c9d55b5 100644 --- a/dlls/ole32/tests/marshal.c +++ b/dlls/ole32/tests/marshal.c @@ -4126,34 +4126,29 @@ again: CloseHandle(handles[1]); }
-static HANDLE create_target_process(const char *arg) +static void create_target_process(const char *arg, PROCESS_INFORMATION *pi) { char **argv; char cmdline[MAX_PATH]; BOOL ret; - PROCESS_INFORMATION pi; STARTUPINFOA si = { 0 }; si.cb = sizeof(si);
- pi.hThread = NULL; - pi.hProcess = NULL; winetest_get_mainargs( &argv ); sprintf(cmdline, ""%s" %s %s", argv[0], argv[1], arg); - ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); + ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, pi); ok(ret, "CreateProcess failed with error: %lu\n", GetLastError()); - if (pi.hThread) CloseHandle(pi.hThread); - return pi.hProcess; }
/* tests functions commonly used by out of process COM servers */ static void test_local_server(void) { + PROCESS_INFORMATION process_info; DWORD cookie; HRESULT hr; IClassFactory * cf; IPersist *persist; DWORD ret; - HANDLE process; HANDLE quit_event; HANDLE ready_event; HANDLE repeat_event; @@ -4214,8 +4209,7 @@ static void test_local_server(void)
CloseHandle(heventShutdown);
- process = create_target_process("-Embedding"); - ok(process != NULL, "couldn't start local server process, error was %ld\n", GetLastError()); + create_target_process("-Embedding", &process_info);
ready_event = CreateEventA(NULL, FALSE, FALSE, "Wine COM Test Ready Event"); ok( !WaitForSingleObject(ready_event, 10000), "wait timed out\n" ); @@ -4246,9 +4240,8 @@ static void test_local_server(void) quit_event = CreateEventA(NULL, FALSE, FALSE, "Wine COM Test Quit Event"); SetEvent(quit_event);
- wait_child_process( process ); + wait_child_process(&process_info); CloseHandle(quit_event); - CloseHandle(process); }
struct git_params diff --git a/dlls/oleacc/tests/main.c b/dlls/oleacc/tests/main.c index 532c5d71257..325ac495e60 100644 --- a/dlls/oleacc/tests/main.c +++ b/dlls/oleacc/tests/main.c @@ -727,7 +727,7 @@ static void test_LresultFromObject(const char *name) memset(&startup, 0, sizeof(startup)); startup.cb = sizeof(startup); CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &proc); - wait_child_process(proc.hProcess); + wait_child_process(&proc); ok(Object_ref == 1, "Object_ref = %ld\n", Object_ref); }
diff --git a/dlls/qmgr/tests/qmgr.c b/dlls/qmgr/tests/qmgr.c index f032f577781..6d788211036 100644 --- a/dlls/qmgr/tests/qmgr.c +++ b/dlls/qmgr/tests/qmgr.c @@ -109,9 +109,7 @@ static void run_child(WCHAR *secret)
wsprintfW(cmdline, L"%s qmgr %s", progname, secret); ok(CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); - wait_child_process(info.hProcess); - ok(CloseHandle(info.hProcess), "CloseHandle\n"); - ok(CloseHandle(info.hThread), "CloseHandle\n"); + wait_child_process(&info); }
static void do_child(const char *secretA) diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c index 07926ee9a36..c05df150542 100644 --- a/dlls/rpcrt4/tests/server.c +++ b/dlls/rpcrt4/tests/server.c @@ -1334,9 +1334,7 @@ run_client(const char *test) client_test_name = test; make_cmdline(cmdline, test); ok(CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &client_info), "CreateProcess\n"); - wait_child_process(client_info.hProcess); - ok(CloseHandle(client_info.hProcess), "CloseHandle\n"); - ok(CloseHandle(client_info.hThread), "CloseHandle\n"); + wait_child_process(&client_info); }
static void @@ -2577,12 +2575,11 @@ static void test_server_listening(void) ok(status == RPC_S_OK, "RpcStringFree\n"); }
-static HANDLE create_server_process(void) +static void create_server_process(PROCESS_INFORMATION *info) { SECURITY_ATTRIBUTES sec_attr = { sizeof(sec_attr), NULL, TRUE }; HANDLE ready_event; char cmdline[MAX_PATH]; - PROCESS_INFORMATION info; STARTUPINFOA startup; DWORD ret;
@@ -2594,13 +2591,11 @@ static HANDLE create_server_process(void)
sprintf(cmdline, "%s server run %Ix", progname, (UINT_PTR)ready_event); trace("running server process...\n"); - ok(CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); + ok(CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, 0L, NULL, NULL, &startup, info), "CreateProcess\n"); ret = WaitForSingleObject(ready_event, 10000); ok(WAIT_OBJECT_0 == ret, "WaitForSingleObject\n");
- ok(CloseHandle(info.hThread), "CloseHandle\n"); ok(CloseHandle(ready_event), "CloseHandle\n"); - return info.hProcess; }
static void run_server(HANDLE ready_event) @@ -2647,13 +2642,13 @@ static void test_reconnect(void) static unsigned char np[] = "ncacn_np"; static unsigned char address_np[] = "\\."; static unsigned char pipe[] = PIPE "term_test"; + PROCESS_INFORMATION info; unsigned char *binding; HANDLE threads[32]; - HANDLE server_process; unsigned i; DWORD ret;
- server_process = create_server_process(); + create_server_process(&info);
ok(RPC_S_OK == RpcStringBindingComposeA(NULL, np, address_np, pipe, NULL, &binding), "RpcStringBindingCompose\n"); ok(RPC_S_OK == RpcBindingFromStringBindingA(binding, &IMixedServer_IfHandle), "RpcBindingFromStringBinding\n"); @@ -2673,17 +2668,15 @@ static void test_reconnect(void)
stop();
- wait_child_process(server_process); - ok(CloseHandle(server_process), "CloseHandle\n"); + wait_child_process(&info);
/* create new server, rpcrt4 will connect to it once sending to existing connection fails * that current connection is broken. */ - server_process = create_server_process(); + create_server_process(&info); basic_tests(); stop();
- wait_child_process(server_process); - ok(CloseHandle(server_process), "CloseHandle\n"); + wait_child_process(&info);
ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); ok(RPC_S_OK == RpcBindingFree(&IMixedServer_IfHandle), "RpcBindingFree\n"); diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c index 3eaace70509..d1674b3ff03 100644 --- a/dlls/shell32/tests/shellpath.c +++ b/dlls/shell32/tests/shellpath.c @@ -1838,7 +1838,7 @@ static void test_NonExistentPath(void) startup.wShowWindow = SW_SHOWNORMAL; CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info); - wait_child_process( info.hProcess ); + wait_child_process( &info );
/* restore original values: */ trace("Restoring CSIDL_FAVORITES to %s\n", originalPath); diff --git a/dlls/shlwapi/tests/ordinal.c b/dlls/shlwapi/tests/ordinal.c index 3c66ce53aea..81a108e4b5f 100644 --- a/dlls/shlwapi/tests/ordinal.c +++ b/dlls/shlwapi/tests/ordinal.c @@ -481,9 +481,7 @@ static void test_alloc_shared(int argc, char **argv) ok(ret, "could not create child process error: %lu\n", GetLastError()); if (ret) { - wait_child_process(pi.hProcess); - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); + wait_child_process(&pi);
p = pSHLockShared(hmem, procid); ok(p != NULL,"SHLockShared failed: %lu\n", GetLastError()); diff --git a/dlls/sxs/tests/sxs.c b/dlls/sxs/tests/sxs.c index 0c367f7c6d5..9bcb85c69aa 100644 --- a/dlls/sxs/tests/sxs.c +++ b/dlls/sxs/tests/sxs.c @@ -231,11 +231,7 @@ static void run_child_process(void) si.cb = sizeof(si); ret = CreateProcessA(exe, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "Could not create process: %lu\n", GetLastError()); - - wait_child_process(pi.hProcess); - - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); + wait_child_process(&pi); }
static void test_SxsLookupClrGuid(void) diff --git a/dlls/ucrtbase/tests/environ.c b/dlls/ucrtbase/tests/environ.c index a42f64466e9..bddf1f78f71 100644 --- a/dlls/ucrtbase/tests/environ.c +++ b/dlls/ucrtbase/tests/environ.c @@ -312,9 +312,7 @@ static void test_child_env(char** argv) snprintf( tmp, sizeof(tmp), "%s %s create", argv[0], argv[1] ); ret = CreateProcessA( NULL, tmp, NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT, env, NULL, &si, &pi ); ok( ret, "Couldn't create child process %s\n", tmp ); - winetest_wait_child_process( pi.hProcess ); - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); + winetest_wait_child_process( &pi ); free( env ); }
diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c index b1de04c3a9d..11472c69f48 100644 --- a/dlls/ucrtbase/tests/misc.c +++ b/dlls/ucrtbase/tests/misc.c @@ -495,9 +495,7 @@ static void test__get_narrow_winmain_command_line(char *path) CreateProcessA(path, cmd, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE|NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, &proc); - wait_child_process(proc.hProcess); - CloseHandle(proc.hProcess); - CloseHandle(proc.hThread); + wait_child_process(&proc); }
static void test__sopen_dispatch(void) diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index 01813e72370..c76205fa31e 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -18629,7 +18629,7 @@ static void launch_test_process(const char *name, const char *test_name) memset(&startup, 0, sizeof(startup)); startup.cb = sizeof(startup); CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &proc); - wait_child_process(proc.hProcess); + wait_child_process(&proc); }
START_TEST(uiautomation) diff --git a/dlls/urlmon/tests/misc.c b/dlls/urlmon/tests/misc.c index b00d978af07..0926eb75224 100644 --- a/dlls/urlmon/tests/misc.c +++ b/dlls/urlmon/tests/misc.c @@ -2003,9 +2003,7 @@ static void test_internet_features(void) { sprintf(cmdline, ""%s" %s internet_features", argv[0], argv[1]); ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "Could not create process: %lu\n", GetLastError()); - wait_child_process( pi.hProcess ); - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); + wait_child_process(&pi);
RegDeleteKeyA(HKEY_CURRENT_USER, szFeatureControlKey); return; diff --git a/dlls/urlmon/tests/sec_mgr.c b/dlls/urlmon/tests/sec_mgr.c index cf2ab577cd0..852ab527520 100644 --- a/dlls/urlmon/tests/sec_mgr.c +++ b/dlls/urlmon/tests/sec_mgr.c @@ -838,9 +838,7 @@ static void run_child_process(void) sprintf(cmdline, ""%s" %s domain_tests", argv[0], argv[1]); ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "Failed to spawn child process: %lu\n", GetLastError()); - wait_child_process(pi.hProcess); - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); + wait_child_process(&pi); }
typedef struct { diff --git a/dlls/user32/tests/class.c b/dlls/user32/tests/class.c index 38490ae2049..4b13f937efa 100644 --- a/dlls/user32/tests/class.c +++ b/dlls/user32/tests/class.c @@ -1391,9 +1391,7 @@ static void test_comctl32_classes(void) sprintf( path_name, "%s class %s", argv[0], classes[i] ); ok( CreateProcessA( NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info ), "CreateProcess failed.\n" ); - wait_child_process( info.hProcess ); - CloseHandle( info.hProcess ); - CloseHandle( info.hThread ); + wait_child_process( &info ); } }
diff --git a/dlls/user32/tests/clipboard.c b/dlls/user32/tests/clipboard.c index 1550bd038ce..e4af56f4776 100644 --- a/dlls/user32/tests/clipboard.c +++ b/dlls/user32/tests/clipboard.c @@ -228,9 +228,7 @@ static void run_process( const char *args ) ok( CreateProcessA( NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info ), "CreateProcess %s failed\n", cmd );
- wait_child_process( info.hProcess ); - CloseHandle( info.hProcess ); - CloseHandle( info.hThread ); + wait_child_process( &info ); }
static WNDPROC old_proc; diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index d23d1ea901c..bc42563b0e4 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -465,8 +465,7 @@ static void test_child_process(void) SendMessageA(child, WM_USER+1, 0, (LPARAM) cursor);
SendMessageA(child, WM_CLOSE, 0, 0); - wait_child_process( info.hProcess ); - CloseHandle( info.hProcess ); + wait_child_process( &info ); }
static BOOL color_match(COLORREF a, COLORREF b) diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 9c1f2ce9c74..ab7dd6b5605 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -481,9 +481,7 @@ static void run_in_process_( const char *file, int line, char **argv, const char ok_(file, line)( ret, "CreateProcessA failed, error %lu\n", GetLastError() ); if (!ret) return;
- wait_child_process( info.hProcess ); - CloseHandle( info.hThread ); - CloseHandle( info.hProcess ); + wait_child_process( &info ); }
#define run_in_desktop( a, b, c ) run_in_desktop_( __FILE__, __LINE__, a, b, c ) @@ -513,9 +511,7 @@ static void run_in_desktop_( const char *file, int line, char **argv, ok_(file, line)( ret, "CreateProcessA failed, error %lu\n", GetLastError() ); if (!ret) return;
- wait_child_process( info.hProcess ); - CloseHandle( info.hThread ); - CloseHandle( info.hProcess ); + wait_child_process( &info );
if (input) { @@ -3162,9 +3158,7 @@ static void test_rawinput(const char* argv0) }
SetEvent(process_ready); - winetest_wait_child_process(process_info.hProcess); - CloseHandle(process_info.hProcess); - CloseHandle(process_info.hThread); + winetest_wait_child_process(&process_info); CloseHandle(process_done); CloseHandle(process_start); CloseHandle(process_ready); diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 8671134f349..a09d752786b 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -19202,11 +19202,11 @@ static void test_WaitForInputIdle( char *argv0 ) WaitForSingleObject( pi.hProcess, 1000 ); /* give it a chance to exit on its own */ } TerminateProcess( pi.hProcess, 0 ); /* just in case */ - wait_child_process( pi.hProcess ); + ret = WaitForSingleObject( pi.hProcess, 30000 ); + ok( !ret, "got %d\n", ret ); ret = WaitForInputIdle( pi.hProcess, 100 ); ok( ret == WAIT_FAILED, "%u: WaitForInputIdle after exit error %08x\n", i, ret ); - CloseHandle( pi.hProcess ); - CloseHandle( pi.hThread ); + wait_child_process( &pi ); } } CloseHandle( end_event ); diff --git a/dlls/user32/tests/scroll.c b/dlls/user32/tests/scroll.c index 70947f5626b..77a34d0cff3 100644 --- a/dlls/user32/tests/scroll.c +++ b/dlls/user32/tests/scroll.c @@ -944,9 +944,7 @@ static void test_cross_process(const char* argv0) ok(ret, "CreateProcess "%s" failed err %lu.\n", path, GetLastError());
/* Messages do not need to be processed to read info. */ - winetest_wait_child_process(process_info.hProcess); - CloseHandle(process_info.hProcess); - CloseHandle(process_info.hThread); + winetest_wait_child_process(&process_info);
sprintf( path, "%s scroll write_process %p", argv0, hMainWnd ); ret = CreateProcessA( NULL, path, NULL, NULL, FALSE, 0, NULL, NULL, &startup_info, &process_info ); @@ -963,9 +961,7 @@ static void test_cross_process(const char* argv0) } }
- winetest_wait_child_process(process_info.hProcess); - CloseHandle(process_info.hProcess); - CloseHandle(process_info.hThread); + winetest_wait_child_process(&process_info);
DestroyWindow( hScroll ); DestroyWindow( hMainWnd ); diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 08b0a5c88e7..f3d78585146 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -3964,9 +3964,7 @@ static void test_SetActiveWindow_0( char **argv ) SetEvent( events[2] ); }
- wait_child_process( info.hProcess ); - CloseHandle( info.hProcess ); - CloseHandle( info.hThread ); + wait_child_process( &info ); CloseHandle( events[1] ); CloseHandle( events[2] );
@@ -10700,11 +10698,9 @@ static void test_window_from_point(HWND main_window, const char *argv0) ok(win == child, "WindowFromPoint returned %p, expected %p\n", win, child);
SetEvent(end_event); - wait_child_process(info.hProcess); + wait_child_process(&info); CloseHandle(start_event); CloseHandle(end_event); - CloseHandle(info.hProcess); - CloseHandle(info.hThread);
DestroyWindow(hwnd); } @@ -11555,9 +11551,7 @@ static void test_winproc_handles(const char *argv0) startup.cb = sizeof(startup); ok(CreateProcessA(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info), "CreateProcess failed.\n"); - wait_child_process(info.hProcess); - CloseHandle(info.hProcess); - CloseHandle(info.hThread); + wait_child_process(&info); }
static void test_winproc_limit(void) @@ -13280,11 +13274,9 @@ static void test_other_process_window(const char *argv0) ret = WaitForSingleObject(test_done_event, 5000); ok(ret == WAIT_OBJECT_0, "Unexpected ret %x.\n", ret);
- wait_child_process(info.hProcess); + wait_child_process(&info); CloseHandle(window_ready_event); CloseHandle(test_done_event); - CloseHandle(info.hProcess); - CloseHandle(info.hThread); DestroyWindow(hwnd); }
diff --git a/dlls/user32/tests/winstation.c b/dlls/user32/tests/winstation.c index 3825829efb7..62f8b10f3cd 100644 --- a/dlls/user32/tests/winstation.c +++ b/dlls/user32/tests/winstation.c @@ -1072,9 +1072,7 @@ static void test_invisible_winstation(char **argv) ret = CreateProcessA(argv[0], buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "CreateProcessA failed, error %lu.\n", GetLastError());
- wait_child_process(pi.hProcess); - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); + wait_child_process(&pi); CloseDesktop(desktop); CloseWindowStation(winstation); SetProcessWindowStation(old_winstation); diff --git a/dlls/vulkan-1/tests/vulkan.c b/dlls/vulkan-1/tests/vulkan.c index 71ad2c4cf34..8f9678aec03 100644 --- a/dlls/vulkan-1/tests/vulkan.c +++ b/dlls/vulkan-1/tests/vulkan.c @@ -1124,9 +1124,8 @@ static void test_cross_process_resource(VkPhysicalDeviceIDPropertiesKHR *device_ kmt ? "kmt" : "nt", handle); res = CreateProcessA(NULL, buf, NULL, NULL, TRUE, 0L, NULL, NULL, &si, &info); ok(res, "CreateProcess failed: %lu\n", GetLastError()); - CloseHandle(info.hThread);
- wait_child_process(info.hProcess); + wait_child_process(&info); }
static void import_memory(VkDevice vk_device, VkMemoryAllocateInfo alloc_info, VkExternalMemoryHandleTypeFlagBits handle_type, HANDLE handle) diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index df548e782ac..3dfc1ae2cb0 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -44,9 +44,7 @@ static void run_in_process_( const char *file, int line, char **argv, const char ok_(file, line)( ret, "CreateProcessA failed, error %lu\n", GetLastError() ); if (!ret) return;
- wait_child_process( info.hProcess ); - CloseHandle( info.hThread ); - CloseHandle( info.hProcess ); + wait_child_process( &info ); }
static void flush_events(void) @@ -1690,10 +1688,7 @@ static void test_inter_process_messages( const char *argv0 ) DispatchMessageW( &msg ); } while (msg.message != WM_USER);
- wait_child_process( pi.hProcess ); - - CloseHandle( pi.hThread ); - CloseHandle( pi.hProcess ); + wait_child_process( &pi );
DestroyWindow( hwnd ); UnregisterClassW( L"TestIPCClass", NULL ); diff --git a/include/wine/test.h b/include/wine/test.h index 7a437fd8c78..6b24eb10ee8 100644 --- a/include/wine/test.h +++ b/include/wine/test.h @@ -93,7 +93,7 @@ extern int winetest_vprintf( const char *msg, va_list args ); extern int winetest_get_time(void);
extern int winetest_get_mainargs( char*** pargv ); -extern void winetest_wait_child_process( HANDLE process ); +extern void winetest_wait_child_process( const PROCESS_INFORMATION *info );
#ifdef STANDALONE #define START_TEST(name) \ @@ -681,14 +681,14 @@ int winetest_get_mainargs( char ***pargv ) return winetest_argc; }
-void winetest_wait_child_process( HANDLE process ) +void winetest_wait_child_process( const PROCESS_INFORMATION *info ) { DWORD ret;
- winetest_ok( process != NULL, "No child process handle (CreateProcess failed?)\n" ); - if (!process) return; + winetest_ok( info->hProcess != NULL, "No child process handle (CreateProcess failed?)\n" ); + if (!info->hProcess) return;
- ret = WaitForSingleObject( process, 30000 ); + ret = WaitForSingleObject( info->hProcess, 30000 ); if (ret == WAIT_TIMEOUT) winetest_ok( 0, "Timed out waiting for the child process\n" ); else if (ret != WAIT_OBJECT_0) @@ -697,13 +697,12 @@ void winetest_wait_child_process( HANDLE process ) else { DWORD exit_code; - GetExitCodeProcess( process, &exit_code ); + GetExitCodeProcess( info->hProcess, &exit_code ); if (exit_code > 255) { - DWORD pid = GetProcessId( process ); winetest_print_lock(); if (winetest_color) winetest_printf( winetest_color_bright_red ); - winetest_print_location( "unhandled exception %08x in child process %04x\n", (UINT)exit_code, (UINT)pid ); + winetest_print_location( "unhandled exception %08x in child process %04x\n", (UINT)exit_code, (UINT)info->dwProcessId ); if (winetest_color) winetest_printf( winetest_color_reset ); winetest_print_unlock(); InterlockedIncrement( &winetest_failures ); @@ -715,6 +714,11 @@ void winetest_wait_child_process( HANDLE process ) winetest_print_unlock(); while (exit_code-- > 0) InterlockedIncrement( &winetest_failures ); } + + if (!CloseHandle( info->hProcess )) + ok( 0, "failed to close process handle, error %lu\n", GetLastError() ); + if (!CloseHandle( info->hThread )) + ok( 0, "failed to close thread handle, error %lu\n", GetLastError() ); } }
diff --git a/programs/conhost/tests/tty.c b/programs/conhost/tests/tty.c index 224a7ccc5cb..5674de1ed3a 100644 --- a/programs/conhost/tests/tty.c +++ b/programs/conhost/tests/tty.c @@ -1764,11 +1764,10 @@ static void child_process(HANDLE pipe) CloseHandle(input); }
-static HANDLE run_child(HANDLE console, HANDLE pipe) +static void run_child(HANDLE console, HANDLE pipe, PROCESS_INFORMATION *info) { STARTUPINFOEXA startup = {{ sizeof(startup) }}; char **argv, cmdline[MAX_PATH]; - PROCESS_INFORMATION info; SIZE_T size; BOOL ret;
@@ -1781,15 +1780,13 @@ static HANDLE run_child(HANDLE console, HANDLE pipe) winetest_get_mainargs(&argv); sprintf(cmdline, ""%s" %s child %p", argv[0], argv[1], pipe); ret = CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL, - &startup.StartupInfo, &info); + &startup.StartupInfo, info); ok(ret, "CreateProcessW failed: %lu\n", GetLastError());
- CloseHandle(info.hThread); HeapFree(GetProcessHeap(), 0, startup.lpAttributeList); - return info.hProcess; }
-static HPCON create_pseudo_console(HANDLE *console_pipe_end, HANDLE *child_process) +static HPCON create_pseudo_console(HANDLE *console_pipe_end, PROCESS_INFORMATION *process_info) { SECURITY_ATTRIBUTES sec_attr = { sizeof(sec_attr), NULL, TRUE }; HANDLE child_pipe_end; @@ -1823,18 +1820,19 @@ static HPCON create_pseudo_console(HANDLE *console_pipe_end, HANDLE *child_proce hres = pCreatePseudoConsole(size, *console_pipe_end, *console_pipe_end, 0, &console); ok(hres == S_OK, "CreatePseudoConsole failed: %08lx\n", hres);
- *child_process = run_child(console, child_pipe_end); + run_child(console, child_pipe_end, process_info); CloseHandle(child_pipe_end); return console; }
static void test_pseudoconsole(void) { - HANDLE console_pipe_end, child_process; + PROCESS_INFORMATION process_info; + HANDLE console_pipe_end; BOOL broken_version; HPCON console;
- console = create_pseudo_console(&console_pipe_end, &child_process); + console = create_pseudo_console(&console_pipe_end, &process_info);
child_string_request(REQ_SET_TITLE, L"test title"); expect_output_sequence("\x1b[2J"); /* erase display */ @@ -1862,8 +1860,7 @@ static void test_pseudoconsole(void) else win_skip("Skipping tty tests on broken Windows version\n");
CloseHandle(child_pipe); - wait_child_process(child_process); - CloseHandle(child_process); + wait_child_process(&process_info);
/* native sometimes clears the screen here */ if (skip_sequence("\x1b[25l"))
 
            On Mon Oct 20 21:42:30 2025 +0000, Elizabeth Figura wrote:
changed this line in [version 3 of the diff](/wine/wine/-/merge_requests/9141/diffs?diff_id=217413&start_sha=58032fde8f8793b239d9b843767e24ce4c937dbc#a729df179302ce80f1c336c407baf3e419a95a15_49_48)
Thanks, I indeed missed that one. Fixed in v2.
 
            If the point is to get rid of `GetProcessId`, maybe we can just remove the call entirely? Having the child process PID printed out doesn't seem very useful to me.
Possibly. I figured it would be easier to just not change that behaviour.
Regarding the other changes, maybe there's a question to whether we want these helpers to do more, or actually do less. Implicitly closing the handles might seem like a useful thing to do, but it might also not be.
I think the wait_child_process helper most important purpose is to add the failure count to the winetest failure count, and possibly print some specific message that the rest of the winetest infrastructure will expect (report parser, etc).
We could argue that the helper should instead be reduced to be made more flexible: the wait could be moved out of the helper and left up to individual test modules (which could use a different timeout strategy), and the exit code could have different meaning depending on the modules.
As I described in the commit message though, this does actually seem to be the more useful arrangement. There are currently 137 users of wait_child_process(); of these one doesn't get the process from CreateProcess() [actually it should be changed no matter what, because currently we're checking for child process failures twice], and only two need to use the handle after waiting for termination [at which point they can still use wait_child_process(), and the line count is even a wash]. Having a dedicated version of wait_child_process() for those two users doesn't even seem like an improvement to me.

