mirror of
https://github.com/swaywm/sway.git
synced 2025-11-08 13:29:50 -05:00
Handle SIGTERM sent to sway
This makes sway handle and gracefully shut down everything when receiving a SIGTERM. Fix #416
This commit is contained in:
parent
b18f004210
commit
16b8c2e915
4 changed files with 24 additions and 7 deletions
|
|
@ -26,6 +26,11 @@ void sway_terminate(void) {
|
|||
wlc_terminate();
|
||||
}
|
||||
|
||||
void sig_handler(int signal) {
|
||||
close_views(&root_container);
|
||||
sway_terminate();
|
||||
}
|
||||
|
||||
static void wlc_log_handler(enum wlc_log_type type, const char *str) {
|
||||
if (type == WLC_LOG_ERROR) {
|
||||
sway_log(L_ERROR, "[wlc] %s", str);
|
||||
|
|
@ -176,6 +181,9 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
register_extensions();
|
||||
|
||||
// handle SIGTERM signals
|
||||
signal(SIGTERM, sig_handler);
|
||||
|
||||
#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE
|
||||
sway_log(L_INFO, "Starting sway version %s (%s, branch \"%s\")\n", SWAY_GIT_VERSION, SWAY_VERSION_DATE, SWAY_GIT_BRANCH);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue