mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-23 11:56:42 +00:00
process(windows): try sending WM_CLOSE for graceful process termination
This commit is contained in:
@@ -520,8 +520,23 @@ done:
|
||||
return result;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK terminate_app(HWND hwnd, LPARAM proc_id)
|
||||
{
|
||||
DWORD current_proc_id = 0;
|
||||
GetWindowThreadProcessId(hwnd, ¤t_proc_id);
|
||||
if (current_proc_id == (DWORD) proc_id) {
|
||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool SDL_SYS_KillProcess(SDL_Process *process, bool force)
|
||||
{
|
||||
if (!force) {
|
||||
EnumWindows(terminate_app, (LPARAM) process->internal->process_information.dwProcessId);
|
||||
PostThreadMessage(process->internal->process_information.dwThreadId, WM_CLOSE, 0, 0);
|
||||
return true;
|
||||
}
|
||||
if (!TerminateProcess(process->internal->process_information.hProcess, 1)) {
|
||||
return WIN_SetError("TerminateProcess failed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user