Skip to content

Commit 4bf3210

Browse files
committed
[SHELL32_APITEST] ShellExecCmdLine: Do **NOT** use TerminateProcess to close the opened windows.
This design, introduced in 418edcd, is fundamentally flawed as it can also close windows unrelated to the running test (e.g. windows of programs that the user can start, while the test is running). But since we cannot do much better, mitigate instead the other main problem of this design: Just use PostMessageW(WM_CLOSE), as it used to be, instead of TerminateProcess(). Indeed, using TerminateProcess() otherwise could kill unrelated processes the test hasn't created. In particular it could kill the csrss.exe system process if, during the testing procedure, a hard-error popup shows up. And this is precisely the case when this test runs with limited memory, and a hard-error "Insufficient system resources exist to complete the requested service." arises.
1 parent 307ce1a commit 4bf3210

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

modules/rostests/apitests/shell32/ShellExecCmdLine.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -609,13 +609,7 @@ static void CleanupNewlyCreatedWindows(void)
609609
}
610610
}
611611
if (!bFound)
612-
{
613-
DWORD dwPID;
614-
GetWindowThreadProcessId(s_wi1.phwnd[i1], &dwPID);
615-
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, TRUE, dwPID);
616-
TerminateProcess(hProcess, -1);
617-
CloseHandle(hProcess);
618-
}
612+
PostMessageW(s_wi1.phwnd[i1], WM_CLOSE, 0, 0);
619613
}
620614
free(s_wi1.phwnd);
621615
ZeroMemory(&s_wi1, sizeof(s_wi1));

0 commit comments

Comments
 (0)