diff --git a/src/main_wayland.cpp b/src/main_wayland.cpp index 944512670d..f108b5f2a3 100644 --- a/src/main_wayland.cpp +++ b/src/main_wayland.cpp @@ -33,6 +33,7 @@ #include #include #include +#include // Qt #include @@ -90,11 +91,6 @@ static void restoreNofileLimit() } } -static void sighandler(int) -{ - QApplication::exit(); -} - void disableDrKonqi() { KCrash::setDrKonqiEnabled(false); @@ -288,15 +284,6 @@ int main(int argc, char *argv[]) KWin::Application::setupLocalizedString(); KWin::gainRealTime(); - if (signal(SIGTERM, KWin::sighandler) == SIG_IGN) { - signal(SIGTERM, SIG_IGN); - } - if (signal(SIGINT, KWin::sighandler) == SIG_IGN) { - signal(SIGINT, SIG_IGN); - } - if (signal(SIGHUP, KWin::sighandler) == SIG_IGN) { - signal(SIGHUP, SIG_IGN); - } signal(SIGPIPE, SIG_IGN); // It's easy to exceed the file descriptor limit because many things are backed using fds @@ -319,6 +306,12 @@ int main(int argc, char *argv[]) // reset QT_QPA_PLATFORM so we don't propagate it to our children (e.g. apps launched from the overview effect) qunsetenv("QT_QPA_PLATFORM"); + KSignalHandler::self()->watchSignal(SIGTERM); + KSignalHandler::self()->watchSignal(SIGINT); + KSignalHandler::self()->watchSignal(SIGHUP); + QObject::connect(KSignalHandler::self(), &KSignalHandler::signalReceived, + &a, &QCoreApplication::exit); + KWin::Application::createAboutData(); QCommandLineOption xwaylandOption(QStringLiteral("xwayland"), diff --git a/src/main_x11.cpp b/src/main_x11.cpp index f80d8917b3..086ba79dba 100644 --- a/src/main_x11.cpp +++ b/src/main_x11.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -51,11 +52,6 @@ Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core", QtWarningMsg) namespace KWin { -static void sighandler(int) -{ - QApplication::exit(); -} - class AlternativeWMDialog : public QDialog { public: @@ -339,15 +335,6 @@ int main(int argc, char *argv[]) KWin::Application::setupMalloc(); KWin::Application::setupLocalizedString(); - if (signal(SIGTERM, KWin::sighandler) == SIG_IGN) { - signal(SIGTERM, SIG_IGN); - } - if (signal(SIGINT, KWin::sighandler) == SIG_IGN) { - signal(SIGINT, SIG_IGN); - } - if (signal(SIGHUP, KWin::sighandler) == SIG_IGN) { - signal(SIGHUP, SIG_IGN); - } signal(SIGPIPE, SIG_IGN); // Disable the glib event loop integration, since it seems to be responsible @@ -375,6 +362,12 @@ int main(int argc, char *argv[]) KWin::ApplicationX11 a(argc, argv); a.setupTranslator(); + KSignalHandler::self()->watchSignal(SIGTERM); + KSignalHandler::self()->watchSignal(SIGINT); + KSignalHandler::self()->watchSignal(SIGHUP); + QObject::connect(KSignalHandler::self(), &KSignalHandler::signalReceived, + &a, &QCoreApplication::exit); + KWin::Application::createAboutData(); QCommandLineOption replaceOption(QStringLiteral("replace"), i18n("Replace already-running ICCCM2.0-compliant window manager"));