projects
/
quassel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implemented a signal handler to graceful shutdown Quassel when SIGTERM or
[quassel.git]
/
src
/
common
/
main.cpp
diff --git
a/src/common/main.cpp
b/src/common/main.cpp
index
fea9d2c
..
86d874b
100644
(file)
--- a/
src/common/main.cpp
+++ b/
src/common/main.cpp
@@
-19,6
+19,7
@@
***************************************************************************/
#include "settings.h"
***************************************************************************/
#include "settings.h"
+#include <QString>
#if defined BUILD_CORE
#include <QCoreApplication>
#if defined BUILD_CORE
#include <QCoreApplication>
@@
-45,7
+46,19
@@
#error "Something is wrong - you need to #define a build mode!"
#endif
#error "Something is wrong - you need to #define a build mode!"
#endif
+#include <signal.h>
+
+//! Signal handler for graceful shutdown.
+void handle_signal(int sig) {
+ qWarning(QString("Caught signal %1 - exiting.").arg(sig).toAscii());
+ QCoreApplication::quit();
+}
+
int main(int argc, char **argv) {
int main(int argc, char **argv) {
+ // We catch SIGTERM and SIGINT (caused by Ctrl+C) to graceful shutdown Quassel.
+ signal(SIGTERM, handle_signal);
+ signal(SIGINT, handle_signal);
+
qRegisterMetaType<Message>("Message");
qRegisterMetaType<BufferId>("BufferId");
qRegisterMetaTypeStreamOperators<Message>("Message");
qRegisterMetaType<Message>("Message");
qRegisterMetaType<BufferId>("BufferId");
qRegisterMetaTypeStreamOperators<Message>("Message");