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 Dec 7, 2023
1 parent 878c0a9 commit 3a6489e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions plugins/protocols/wayfire-shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,11 @@ class wayfire_shell_protocol_impl : public wf::plugin_interface_t

void fini() override
{
if (wf::get_core().get_current_state() == wf::compositor_state_t::SHUTDOWN)
{
return;
}

wl_global_destroy(wf_shell->shell_manager);
delete wf_shell;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ void program_t::free_resources()
{
for (int i = 0; i < wf::TEXTURE_TYPE_ALL; i++)
{
if (this->priv->id[i])
if (this->priv && this->priv->id[i])
{
GL_CALL(glDeleteProgram(priv->id[i]));
this->priv->id[i] = 0;
Expand Down
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 3a6489e

Please sign in to comment.