Stop the service if the user quits via the tray icon

This commit is contained in:
Cameron Gutman 2023-04-15 17:51:32 -05:00
commit f51876893e
5 changed files with 56 additions and 13 deletions

View file

@ -301,9 +301,16 @@ ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv) {
}
break;
case WAIT_OBJECT_0 + 1:
case WAIT_OBJECT_0 + 1: {
// Sunshine terminated itself.
DWORD exit_code;
if (GetExitCodeProcess(process_info.hProcess, &exit_code) && exit_code == ERROR_SHUTDOWN_IN_PROGRESS) {
// Sunshine is asking for us to shut down, so gracefully stop ourselves.
SetEvent(stop_event);
}
break;
}
}
CloseHandle(process_info.hThread);