aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2017-04-04 09:34:53 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2017-04-04 08:12:20 +0000
commit3a9aa1a0beeef9c39f92b103460b5a754df90667 (patch)
treef1023a3db558240da203ee7b909e802f3a0fb25b
parent6e39b6e65eff9442587bcdfba1c39564a6c83320 (diff)
Fix hang after Ctrl-C on Windows
The processlauncher must ignore Ctrl-C/Ctrl-Break on Windows. It will be shut down by its parent process, which is not prepared for the launcher to suddenly disappear. Change-Id: I63a9bcf84bafcb874e0165edf5d127d66784f071 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/libexec/qbs_processlauncher/processlauncher-main.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libexec/qbs_processlauncher/processlauncher-main.cpp b/src/libexec/qbs_processlauncher/processlauncher-main.cpp
index 9d51c9fa1..4ecc3e660 100644
--- a/src/libexec/qbs_processlauncher/processlauncher-main.cpp
+++ b/src/libexec/qbs_processlauncher/processlauncher-main.cpp
@@ -32,8 +32,22 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qtimer.h>
+#ifdef Q_OS_WIN
+#include <QtCore/qt_windows.h>
+
+BOOL consoleCtrlHandler(DWORD)
+{
+ // Ignore Ctrl-C / Ctrl-Break. Qbs will tell us to exit gracefully.
+ return TRUE;
+}
+#endif
+
int main(int argc, char *argv[])
{
+#ifdef Q_OS_WIN
+ SetConsoleCtrlHandler(consoleCtrlHandler, TRUE);
+#endif
+
QCoreApplication app(argc, argv);
if (app.arguments().count() != 2) {
qbs::Internal::logError("Need exactly one argument (path to socket)");