Skip to content

Commit a6c0027

Browse files
committed
Use job object to kill CEF process on exit (Fixes #4032)
1 parent 3a7fa32 commit a6c0027

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

Client/ceflauncher_DLL/Main.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
/*****************************************************************************
22
*
3-
* PROJECT: Multi Theft Auto v1.0
4-
* (Shared logic for modifications)
3+
* PROJECT: Multi Theft Auto
54
* LICENSE: See LICENSE in the top level directory
65
* FILE: ceflauncher/Main.cpp
76
* PURPOSE: CEF launcher entry point
87
*
8+
* Multi Theft Auto is available from https://multitheftauto.com/
9+
*
910
*****************************************************************************/
11+
1012
#define WIN32_LEAN_AND_MEAN
1113
#include <Windows.h>
1214
#include <delayimp.h>
@@ -44,5 +46,20 @@ int _declspec(dllexport) InitCEF()
4446
sandboxInfo = scopedSandbox.sandbox_info();
4547
#endif
4648

49+
if (HANDLE job = CreateJobObjectW(nullptr, nullptr); job != nullptr)
50+
{
51+
JOBOBJECT_EXTENDED_LIMIT_INFORMATION limits{};
52+
limits.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
53+
54+
if (SetInformationJobObject(job, JobObjectExtendedLimitInformation, &limits, sizeof(limits)))
55+
{
56+
AssignProcessToJobObject(job, GetCurrentProcess());
57+
}
58+
else
59+
{
60+
CloseHandle(job);
61+
}
62+
}
63+
4764
return CefExecuteProcess(mainArgs, app, sandboxInfo);
4865
}

0 commit comments

Comments
 (0)