Support both Unix and Windows variants of signal API

This commit is contained in:
Emil Lundberg 2019-11-26 14:32:15 +01:00
parent 729339d2be
commit 2066904b3c
No known key found for this signature in database
GPG Key ID: D8588A5844E2A774

View File

@ -14,7 +14,10 @@ void handleExitSignal(int sig) {
QCoreApplication::quit();
}
void setupUnixSignals() {
void setupSignalHandlers() {
#ifdef _WIN32
signal(SIGINT, handleExitSignal);
#else
struct sigaction sa;
sa.sa_handler = handleExitSignal;
sigset_t signal_mask;
@ -22,11 +25,12 @@ void setupUnixSignals() {
sa.sa_mask = signal_mask;
sa.sa_flags = 0;
sigaction(SIGINT, &sa, nullptr);
#endif
}
int main(int argc, char *argv[])
{
setupUnixSignals();
setupSignalHandlers();
// Don't write .pyc files.
qputenv("PYTHONDONTWRITEBYTECODE", "1");