CuteHMI - Daemon (cutehmi.daemon.1)
Daemon_unix.hpp
1 #ifndef H_TOOLS_CUTEHMI_DAEMON_1_SRC_CUTEHMI_DAEMON_DAEMON_u_UNIX_HPP
2 #define H_TOOLS_CUTEHMI_DAEMON_1_SRC_CUTEHMI_DAEMON_DAEMON_u_UNIX_HPP
3 
4 #include <QObject>
5 #include <QSocketNotifier>
6 
7 #include <memory>
8 
9 namespace cutehmi {
10 namespace daemon {
11 
12 class Daemon;
13 
17 class _Daemon:
18  public QObject
19 {
20  Q_OBJECT
21 
22  public:
23  static int signalFd[2];
24 
25  _Daemon(const QString & pidFile);
26 
28 
29  void initializePidFile();
30 
31  void destroyPidFile();
32 
33  signals:
34  void exitRequested(int exitCode);
35 
36  private slots:
37  void handleSignal();
38 
39  private:
40  int createPidFile();
41 
42  void lockPidFile();
43 
44  void writePidFile();
45 
46  void removePidFile();
47 
48  private:
49  QString m_pidFile;
50  int m_pidFd;
51  std::unique_ptr<QSocketNotifier> m_signalSocketNotifier;
52  std::unique_ptr<QSocketNotifier> m_unhandledSignalsSocketNotifier;
53 };
54 
55 
56 }
57 }
58 
59 #endif
60 
61 //(c)C: Copyright © 2020, Michał Policht <michal@policht.pl>. All rights reserved.
62 //(c)C: This file is a part of CuteHMI.
63 //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
64 //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
65 //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see <https://www.gnu.org/licenses/>.
cutehmi::daemon::_Daemon::initializeSignalHandling
void initializeSignalHandling()
Definition: Daemon_unix.cpp:81
QObject
cutehmi
QString
cutehmi::daemon::_Daemon::destroyPidFile
void destroyPidFile()
Definition: Daemon_unix.cpp:99
cutehmi::daemon::_Daemon::initializePidFile
void initializePidFile()
Definition: Daemon_unix.cpp:92
cutehmi::daemon::_Daemon
Unix-specific daemon helper.
Definition: Daemon_unix.hpp:17
std::unique_ptr< QSocketNotifier >
cutehmi::daemon::_Daemon::exitRequested
void exitRequested(int exitCode)
cutehmi::daemon::_Daemon::_Daemon
_Daemon(const QString &pidFile)
Definition: Daemon_unix.cpp:75
cutehmi::daemon::_Daemon::signalFd
static int signalFd[2]
Definition: Daemon_unix.hpp:23