diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2020-04-14 17:26:50 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2020-04-15 11:14:59 +0000 |
commit | dcbb9872d3ef87e809e58329a00414f2e6a11f25 (patch) | |
tree | c19164015b653913599cd7f07b2f2fb86cdb75f1 | |
parent | b26370f05d26f934550f7b63227188967b2f6dc5 (diff) |
qbs session: Keep checking whether stdin is still present
Otherwise, we will continue to lock the build directory if the
controlling process dies.
This patch implements the solution for Unix. The Windows one will follow
shortly.
Task-number: QTCREATORBUG-23839
Change-Id: I95ca7f6666e520c78521af1e85b765bc2e266e0f
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r-- | src/app/qbs/stdinreader.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/app/qbs/stdinreader.cpp b/src/app/qbs/stdinreader.cpp index b90abf9d1..1ae662aab 100644 --- a/src/app/qbs/stdinreader.cpp +++ b/src/app/qbs/stdinreader.cpp @@ -43,13 +43,13 @@ #include <QtCore/qfile.h> #include <QtCore/qsocketnotifier.h> +#include <QtCore/qtimer.h> #include <cerrno> #include <cstring> #ifdef Q_OS_WIN32 #include <qt_windows.h> -#include <QtCore/qtimer.h> #else #include <fcntl.h> #endif @@ -87,6 +87,18 @@ private: connect(&m_notifier, &QSocketNotifier::activated, this, [this] { emit dataAvailable(m_stdIn.readAll()); }); + + // Neither the aboutToClose() nor the readChannelFinished() signals + // are triggering, so we need a timer to check whether the controlling + // process disappeared. + const auto stdinClosedChecker = new QTimer(this); + connect(stdinClosedChecker, &QTimer::timeout, this, [this, stdinClosedChecker] { + if (m_stdIn.atEnd()) { + stdinClosedChecker->stop(); + emit errorOccurred(tr("Input channel closed unexpectedly.")); + } + }); + stdinClosedChecker->start(1000); } QFile m_stdIn; |