Commit 8c267ea4 authored by Lisa's avatar Lisa
Browse files

Deinitialized backend in fault situations

parent 93cbb2fc
......@@ -157,3 +157,9 @@ void OperationManager::quit()
void OperationManager::staticQuit(int sig)
......@@ -23,6 +23,9 @@ Q_OBJECT
explicit OperationManager(APM::OperationType type, QList< APM::OperationName > operations, QHash<APM::OptionName, QStringList> options, QStringList args, QObject* parent = 0);
virtual ~OperationManager();
/* This is just the static version of the quit() slot below, to be passed as a signal handler to sigaction(3) */
static void staticQuit(int);
private slots:
void statusChanged(Akabei::Backend::Status);
......@@ -19,6 +19,8 @@
#include <akabeiaboutdata.h>
#include <stdlib.h>
#include <signal.h>
#include <QCoreApplication>
#include <QTextStream>
#include <QHash>
......@@ -356,6 +358,18 @@ void initPakabeiOperations(CommandLineParser *parser)
void connectMainSignals()
struct sigaction act;
memset(&act, 0, sizeof(struct sigaction));
act.sa_handler = OperationManager::staticQuit;
sigaction(SIGINT, &act, NULL);
sigaction(SIGQUIT, &act, NULL);
sigaction(SIGABRT, &act, NULL);
sigaction(SIGTERM, &act, NULL);
int main(int argc, char **argv)
QCoreApplication app(argc, argv);
......@@ -406,6 +420,11 @@ int main(int argc, char **argv)
* If we arrived here, akabei is going to initialize the backend soon. Here we make sure it is always
* de-initialized properly even when akabei is terminated with CTRL+C, or because of a segfault.
OperationManager apm(parser->type(), parser->operations(), parser->options(), parser->args());
delete parser;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment