2
* Copyright (C) 2010 Ivan Cukic <ivan.cukic(at)kde.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2,
6
* or (at your option) any later version, as published by the Free
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details
14
* You should have received a copy of the GNU General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
#include <ActivityManager.h>
26
#include <KCmdLineArgs>
31
#include "jobs/encryption/Common.h"
33
static void initSignalCatching();
35
int main(int argc, char ** argv)
37
KAboutData about("kactivitymanagerd", 0, ki18n("KDE Activity Manager"), "2.0",
38
ki18n("KDE Activity Management Service"),
39
KAboutData::License_GPL,
40
ki18n("(c) 2010, 2011, 2012 Ivan Cukic, Sebastian Trueg"), KLocalizedString(),
41
"http://www.kde.org/");
43
KCmdLineArgs::init(argc, argv, &about);
45
ActivityManager application;
49
return application.exec();
53
static void signalHandler(int sig)
55
Jobs::Encryption::Common::unmountAll();
57
// something (probably ksmserver) has asked us to terminate.
58
// If it is really ksmserver then the user is probably logging out, so we
59
// had better gently stop now than be killed.
61
//qDebug() << "signalHandler(SIGTERM): stopping ActivityManager\n";
63
ActivityManager::self()->Stop();
66
// If we have crashed, then restart
68
qDebug() << "Calling the crash handler...";
69
KCrash::defaultCrashHandler(SIGSEGV);
75
static void initSignalCatching() {
76
#ifndef Q_OS_WIN32 // krazy:skip
77
struct sigaction action;
79
::sigemptyset(&action.sa_mask);
82
/* Use the sa_sigaction field because the handles has two additional parameters */
83
action.sa_handler = signalHandler;
85
::sigaction(SIGINT, &action, NULL);
86
::sigaction(SIGHUP, &action, NULL);
87
::sigaction(SIGTERM, &action, NULL);
88
::sigaction(SIGSEGV, &action, NULL);