Handle SIGINT (Ctrl-C) like SIGTERM for graceful shutdown

This commit is contained in:
Andrew Hamilton 2026-08-09 11:50:40 +10:00
parent 3381193f11
commit b80871c62c

View file

@ -1940,9 +1940,10 @@ static void sigchld_handler(int sig) {
}
}
/* On an external SIGTERM, take down the clients and exit cleanly rather than
leaving them orphaned when the compositor dies. */
static void sigterm_handler(int sig) {
/* On SIGTERM or Ctrl-C (SIGINT), take down the clients and exit cleanly
rather than leaving them orphaned when the compositor dies. The clients
live in their own process groups, so a terminal Ctrl-C only reaches us. */
static void close_signal_handler(int sig) {
(void)sig;
shutdown_cleanup();
_exit(0);
@ -1974,7 +1975,8 @@ int main(int argc, char *argv[]) {
sigaction(SIGSEGV, &crash_sa, NULL);
sigaction(SIGABRT, &crash_sa, NULL);
signal(SIGCHLD, sigchld_handler);
signal(SIGTERM, sigterm_handler);
signal(SIGTERM, close_signal_handler);
signal(SIGINT, close_signal_handler);
signal(SIGUSR1, sigusr1_handler);
/* wlroots logs follow TABBED_LOG: quiet keeps only errors, info drops