mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-23 18:58:29 +03:00
Merge pull request #493 from Yubico/python38-signal
Move signal handler setup to C++ layer
This commit is contained in:
commit
24ae87a286
22
main.cpp
22
main.cpp
@ -2,14 +2,36 @@
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlContext>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <QtGlobal>
|
||||
#include <QtWidgets>
|
||||
#include <QQuickWindow>
|
||||
#include <QQuickStyle>
|
||||
#include "screenshot.h"
|
||||
|
||||
void handleExitSignal(int sig) {
|
||||
printf("Exiting due to signal %d\n", sig);
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
|
||||
void setupSignalHandlers() {
|
||||
#ifdef _WIN32
|
||||
signal(SIGINT, handleExitSignal);
|
||||
#else
|
||||
struct sigaction sa;
|
||||
sa.sa_handler = handleExitSignal;
|
||||
sigset_t signal_mask;
|
||||
sigemptyset(&signal_mask);
|
||||
sa.sa_mask = signal_mask;
|
||||
sa.sa_flags = 0;
|
||||
sigaction(SIGINT, &sa, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
setupSignalHandlers();
|
||||
|
||||
// Don't write .pyc files.
|
||||
qputenv("PYTHONDONTWRITEBYTECODE", "1");
|
||||
|
||||
|
@ -23,8 +23,6 @@ from ykman.oath import (
|
||||
from ykman.otp import OtpController
|
||||
from ykman.settings import Settings
|
||||
from qr import qrparse, qrdecode
|
||||
import signal
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
Loading…
Reference in New Issue
Block a user