From 8536130aa27b0cee65fbffa9abfdcdbce6e7821f Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 28 Feb 2018 01:23:49 -0500 Subject: [PATCH] assert: Use TerminateProcess() on Windows, vs ExitProcess (thanks, Jack!). "What I have done is use TerminateProcess rather than ExitProcess. ExitProcess will cause Microsoft's leak detection to continue, TerminateProcess won't. It is also technically wrong to use ExitProcess in the case of aborting the application. Jack Powell Twitter @jack9267" --- src/SDL_assert.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/SDL_assert.c b/src/SDL_assert.c index 76f5d604d70e6..bee07a9ed9dfe 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -123,7 +123,11 @@ static void SDL_GenerateAssertionReport(void) static SDL_NORETURN void SDL_ExitProcess(int exitcode) { #ifdef __WIN32__ - ExitProcess(exitcode); + /* "if you do not know the state of all threads in your process, it is + better to call TerminateProcess than ExitProcess" + https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx */ + TerminateProcess(GetCurrentProcess(), exitcode); + #elif defined(__EMSCRIPTEN__) emscripten_cancel_main_loop(); /* this should "kill" the app. */ emscripten_force_exit(exitcode); /* this should "kill" the app. */