Add Ctrl-C cleanup for Drone on Windows

This commit is contained in:
Srivats P 2020-12-27 12:54:57 +05:30
parent 4ae6b564d3
commit 33dbc42ecb

View File

@ -28,9 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include <QCoreApplication> #include <QCoreApplication>
#include <QFile> #include <QFile>
#ifdef Q_OS_UNIX
#include <signal.h> #include <signal.h>
#endif
extern ProtocolManager *OstProtocolManager; extern ProtocolManager *OstProtocolManager;
extern char *version; extern char *version;
@ -100,6 +98,11 @@ int main(int argc, char *argv[])
qDebug("Failed to install SIGTERM handler. Cleanup may not happen!!!"); qDebug("Failed to install SIGTERM handler. Cleanup may not happen!!!");
if (sigaction(SIGINT, &sa, NULL)) if (sigaction(SIGINT, &sa, NULL))
qDebug("Failed to install SIGINT handler. Cleanup may not happen!!!"); qDebug("Failed to install SIGINT handler. Cleanup may not happen!!!");
#elif defined(Q_OS_WIN32)
if (signal(SIGTERM, cleanup) == SIG_ERR)
qDebug("Failed to install SIGTERM handler. Cleanup may not happen!!!");
if (signal(SIGINT, cleanup) == SIG_ERR)
qDebug("Failed to install SIGINT handler. Cleanup may not happen!!!");
#endif #endif
exitCode = app.exec(); exitCode = app.exec();