start: Wrap child inside a job so it gets killed when start.exe terminates.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50869
Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Eric Pouech 2022-01-25 08:31:34 +01:00 committed by Alexandre Julliard
parent 53b179dcc1
commit a1abb524fe
1 changed files with 17 additions and 0 deletions

View File

@ -676,7 +676,24 @@ done:
if (sei.fMask & SEE_MASK_NOCLOSEPROCESS) {
DWORD exitcode;
HANDLE hJob;
JOBOBJECT_EXTENDED_LIMIT_INFORMATION info;
SetConsoleCtrlHandler(NULL, TRUE);
hJob = CreateJobObjectA(NULL, NULL);
/* Create a job where the child is associated... if the start.exe terminates
* before the child, the job will be terminated, and the child will be terminated as well.
* (The idea is to allow to kill (from a Unix standpoint) a created Windows
* process (here start.exe), and that the unix-kill of start.exe will be also terminate
* start.exe's child process).
*/
memset(&info, 0, sizeof(info));
info.BasicLimitInformation.LimitFlags =
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE |
JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK;
SetInformationJobObject(hJob, JobObjectExtendedLimitInformation, &info, sizeof(info));
AssignProcessToJobObject(hJob, sei.hProcess);
WaitForSingleObject(sei.hProcess, INFINITE);
GetExitCodeProcess(sei.hProcess, &exitcode);
ExitProcess(exitcode);