Skip to content

Commit

Permalink
Call shutdown on SIGINT/SIGTERM
Browse files Browse the repository at this point in the history
Fixes #729.
  • Loading branch information
soreau committed Mar 8, 2024
1 parent 878c0a9 commit 8db003a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ static void signal_handler(int signal)
error = "Fatal error(SIGABRT)";
break;

case SIGINT:
LOGI("Got SIGINT, shutting down");
wf::get_core().shutdown();
return;

case SIGTERM:
LOGI("Got SIGTERM, shutting down");
wf::get_core().shutdown();
return;

default:
error = "Unknown";
}
Expand Down Expand Up @@ -324,6 +334,9 @@ int main(int argc, char *argv[])
signal(SIGABRT, signal_handler);
#endif

signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);

std::set_terminate([] ()
{
std::cout << "Unhandled exception" << std::endl;
Expand Down Expand Up @@ -420,5 +433,7 @@ int main(int argc, char *argv[])
/* Teardown */
wl_display_destroy_clients(core.display);
wl_display_destroy(core.display);

LOGI("EXIT_SUCCESS");
return EXIT_SUCCESS;
}

0 comments on commit 8db003a

Please sign in to comment.