| 1 | // Copyright 2018 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include <QObject> |
| 7 | |
| 8 | class QSocketNotifier; |
| 9 | |
| 10 | // Loosely based on https://doc.qt.io/qt-5.9/unix-signals.html |
| 11 | class SignalDaemon : public QObject |
| 12 | { |
| 13 | Q_OBJECT |
| 14 | |
| 15 | public: |
| 16 | explicit SignalDaemon(QObject* parent); |
| 17 | ~SignalDaemon(); |
| 18 | |
| 19 | static void HandleInterrupt(int); |
| 20 | |
| 21 | signals: |
| 22 | void InterruptReceived(); |
| 23 | |
| 24 | private: |
| 25 | void OnNotifierActivated(); |
| 26 | |
| 27 | static int s_sigterm_fd[2]; |
| 28 | |
| 29 | QSocketNotifier* m_term; |
| 30 | }; |