[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.
This commit is contained in:
Hermès Bélusca-Maïto 2022-05-05 22:21:21 +02:00
parent 307ce1a503
commit 4bf32102ab
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -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));