Buteo Synchronization Framework
SyncSigHandler.h
1/*
2 * This file is part of buteo-syncfw package
3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 *
6 * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#ifndef SYNCSIGHANDLER_H
25#define SYNCSIGHANDLER_H
26
27#include <QSocketNotifier>
39class SyncSigHandler : public QObject
40{
41 Q_OBJECT
42
43public:
49 SyncSigHandler(QObject *aParent = 0, const char *aName = 0);
50
55
56 // Unix signal handlers.
57 static void hupSignalHandler(int unused);
58 static void termSignalHandler(int unused);
59
60public slots:
65 void handleSigHup();
66
71 void handleSigTerm();
72
73private:
74 //socket pair for each Unix signal to handle
75 static int iSigHupFd[2];
76 static int iSigTermFd[2];
77
78 //QSocketNotifier to monitor the read end of each socket pair,
79 // declare your Unix signal handlers to be static class methods
80 QSocketNotifier *iSigHup;
81 QSocketNotifier *iSigTerm;
82
83#ifdef SYNCFW_UNIT_TESTS
84 friend class SyncSigHandlerTest;
85#endif
86};
87
88
89#endif // SYNCSIGHANDLER_H
About this class. We can't call Qt functions from Unix signal handlers.We can only call async-signal-...
Definition: SyncSigHandler.h:40
~SyncSigHandler()
Destructor.
Definition: SyncSigHandler.cpp:64
SyncSigHandler(QObject *aParent=0, const char *aName=0)
Constructor.
Definition: SyncSigHandler.cpp:37
void handleSigTerm()
QT signal handler to handle SIG_TERM.
Definition: SyncSigHandler.cpp:87
void handleSigHup()
QT signal handler to handle SIG_HUP.
Definition: SyncSigHandler.cpp:98