From ddf7aa85ec7bada4a96b2692e4b9f1bdd709cbad Mon Sep 17 00:00:00 2001 From: Niels Weber Date: Thu, 27 Mar 2014 11:12:07 +0100 Subject: Fix hang when entering wrong sudo pw Task-number: QTIFW-451 Task-number: QTIFW-409 Change-Id: I83ebd338b5f52f2a0b3b1fabcce8fb98afce5e19 Reviewed-by: Karsten Heimrich --- src/libs/installer/adminauthorization_x11.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libs/installer/adminauthorization_x11.cpp b/src/libs/installer/adminauthorization_x11.cpp index 6d5a52357..9cce8a08b 100644 --- a/src/libs/installer/adminauthorization_x11.cpp +++ b/src/libs/installer/adminauthorization_x11.cpp @@ -177,19 +177,21 @@ bool AdminAuthorization::execute(QWidget *parent, const QString &program, const QRegExp re(QLatin1String("[Pp]assword.*:")); QByteArray errData; flags = ::fcntl(masterFD, F_GETFD); -// if (flags != -1) -// ::fcntl(masterFD, F_SETFL, flags | O_NONBLOCK); int bytes = 0; int errBytes = 0; char buf[1024]; + char errBuf[1024]; while (bytes >= 0) { int state; if (::waitpid(child, &state, WNOHANG) == -1) break; bytes = ::read(masterFD, buf, 1023); - errBytes = ::read(pipedData[0], buf, 1023); + errBytes = ::read(pipedData[0], errBuf, 1023); if (errBytes > 0) + { errData.append(buf, errBytes); + errBytes=0; + } if (bytes > 0) { const QString line = QString::fromLatin1(buf, bytes); if (re.indexIn(line) != -1) { -- cgit v1.2.3