mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-11-30 19:37:15 -05:00
Implement clean shutdown after receiving Unix signals, resolves #169
The database wasn't saved properly and lockfiles were not removed when receiving the signals SIGINT, SIGTERM, SIGQUIT or SIGHUP. This patch implements signal handling and performs a clean shutdown after receiving SIGINT SIGTERM or SIGQUIT and ignores SIGHUP. Since this uses POSIX syscalls for signal and socket handling, there is no Windows implementation at the moment.
This commit is contained in:
parent
72b81bf403
commit
198691182b
3 changed files with 83 additions and 3 deletions
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include <QApplication>
|
||||
|
||||
class QSocketNotifier;
|
||||
|
||||
class Application : public QApplication
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -34,8 +36,21 @@ public:
|
|||
Q_SIGNALS:
|
||||
void openFile(const QString& filename);
|
||||
|
||||
private:
|
||||
private Q_SLOTS:
|
||||
void quitBySignal();
|
||||
|
||||
private:
|
||||
QWidget* m_mainWindow;
|
||||
|
||||
#if defined(Q_OS_UNIX)
|
||||
/**
|
||||
* Register Unix signals such as SIGINT and SIGTERM for clean shutdown.
|
||||
*/
|
||||
void registerUnixSignals();
|
||||
QSocketNotifier* m_unixSignalNotifier;
|
||||
static void handleUnixSignal(int sig);
|
||||
static int unixSignalSocket[2];
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_APPLICATION_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue