https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4bf32102abfacf4917dd18...
commit 4bf32102abfacf4917dd18d00673608a8fa877c7 Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Thu May 5 22:21:21 2022 +0200 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Fri May 6 21:32:08 2022 +0200
[SHELL32_APITEST] ShellExecCmdLine: Do **NOT** use TerminateProcess to close the opened windows.
This design, introduced in 418edcd2b, 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. --- modules/rostests/apitests/shell32/ShellExecCmdLine.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/modules/rostests/apitests/shell32/ShellExecCmdLine.cpp b/modules/rostests/apitests/shell32/ShellExecCmdLine.cpp index e869e6deee5..218ff08ed88 100644 --- a/modules/rostests/apitests/shell32/ShellExecCmdLine.cpp +++ b/modules/rostests/apitests/shell32/ShellExecCmdLine.cpp @@ -609,13 +609,7 @@ static void CleanupNewlyCreatedWindows(void) } } if (!bFound) - { - DWORD dwPID; - GetWindowThreadProcessId(s_wi1.phwnd[i1], &dwPID); - HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, TRUE, dwPID); - TerminateProcess(hProcess, -1); - CloseHandle(hProcess); - } + PostMessageW(s_wi1.phwnd[i1], WM_CLOSE, 0, 0); } free(s_wi1.phwnd); ZeroMemory(&s_wi1, sizeof(s_wi1));