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
parent dd6fcbd7b8
commit f51876893e
5 changed files with 56 additions and 13 deletions

View File

@@ -131,7 +131,15 @@ namespace system_tray {
tray_quit_cb(struct tray_menu *item) {
BOOST_LOG(info) << "Quiting from system tray"sv;
std::raise(SIGINT);
#ifdef _WIN32
// If we're running in a service, return a special status to
// tell it to terminate too, otherwise it will just respawn us.
if (GetConsoleWindow() == NULL) {
lifetime::exit_sunshine(ERROR_SHUTDOWN_IN_PROGRESS, false);
}
#endif
lifetime::exit_sunshine(0, false);
}
// Tray menu