From 3f2d4bb80db5c04bfd4c47696049f7ba7233a6f7 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 30 Jun 2016 15:36:44 -0400 Subject: Ensure that the quick command run routine will never hang the system for more than 1 second of inactivity from the subprocess. --- src-qt5/core/libLumina/LuminaUtils.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src-qt5/core/libLumina/LuminaUtils.cpp b/src-qt5/core/libLumina/LuminaUtils.cpp index 1d0e186c..76d61f8d 100644 --- a/src-qt5/core/libLumina/LuminaUtils.cpp +++ b/src-qt5/core/libLumina/LuminaUtils.cpp @@ -34,15 +34,19 @@ inline QStringList ProcessRun(QString cmd, QStringList args){ proc.setProcessEnvironment(env); proc.setProcessChannelMode(QProcess::MergedChannels); if(args.isEmpty()){ - proc.start(cmd); + proc.start(cmd, QIODevice::ReadOnly); }else{ - proc.start(cmd,args); + proc.start(cmd,args ,QIODevice::ReadOnly); } - while(!proc.waitForFinished(500)){ + QString info; + while(!proc.waitForFinished(1000)){ if(proc.state() == QProcess::NotRunning){ break; } //somehow missed the finished signal + QString tmp = proc.readAllStandardOutput(); + if(tmp.isEmpty()){ proc.terminate(); } + else{ info.append(tmp); } } out[0] = QString::number(proc.exitCode()); - out[1] = QString(proc.readAllStandardOutput()); + out[1] = info+QString(proc.readAllStandardOutput()); return out; } //============= -- cgit