Merge pull request #493 from Yubico/python38-signal

Move signal handler setup to C++ layer
This commit is contained in:
Emil Lundberg 2019-11-28 14:01:59 +01:00 committed by GitHub
commit 24ae87a286
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -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");

View File

@ -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__)