[Interest] The right way of using QProcess

Nuno Santos nunosantos at imaginando.pt
Tue May 19 20:08:10 CEST 2015


Thiago,

I have found the cause. The command binary was not present on the directory thus, every call was being invoked without the program. It never started, it never ended. 

You were right. It was a zombie attack.

Nuno Santos
Founder / CEO / CTO
www.imaginando.pt
+351 91 621 69 62

> On 19 May 2015, at 16:12, Nuno Santos <nunosantos at imaginando.pt> wrote:
> 
> Thiago,
> 
> Thanks for your reply. Yes, this is 5.4.
> 
> I will investigate this further by doing some output on the waitForFinished return result.
> 
> I want to avoid installing another toolkit right now (lack of time and lack of space in my laptop) but I will consider it if the problems persists.
> 
> Regards,
> 
> Nuno Santos
> Founder / CEO / CTO
> www.imaginando.pt <http://www.imaginando.pt/>
> +351 91 621 69 62
> 
>> On 19 May 2015, at 15:58, Thiago Macieira <thiago.macieira at intel.com <mailto:thiago.macieira at intel.com>> wrote:
>> 
>> On Tuesday 19 May 2015 15:29:04 Nuno Santos wrote:
>>> Hi,
>>> 
>>> I’m calling the function below with a one second interval while my app is
>>> open. The functions executes the command “adb devices"
>>> 
>>> Is there any kind of limitation by the system by the number of calls? I
>>> think my system gets to a point where no more processes can be created:
>>> Chrome starts to hang, QtCreator isn’t able to do make, etc
>> 
>> Sounds like an attack of the zombies.... (no, really, there must be zombie 
>> process left around)
>> 
>>> 
>>> static QString executeAdbCommand(QStringList arguments)
>>> {
>>>    QProcess p;
>>> 
>>>    //p.setReadChannel(QProcess::StandardError);
>>> 
>>>    #ifdef Q_OS_MAC
>>>    p.start(QString("%1/adb").arg(QCoreApplication::applicationDirPath()),
>>> arguments); #endif
>>> 
>>>    #ifdef Q_OS_WIN
>>>    p.start("adb.exe", arguments);
>>>    #endif
>>> 
>>>    //qDebug() << "Executing adb" << arguments;
>>> 
>>>    if (!p.waitForStarted())
>>>       return "";
>>> 
>>>    if (!p.waitForFinished())
>>>       return "";
>>> 
>>>    QString output = p.readAll();
>>> 
>>>    return output;
>>> }
>> 
>> Don't return until waitForFinished() succeeds. That one guarantees wait() has 
>> happened on the process, so we know there is no zombie left.
>> 
>> Is this Qt 5.4? Or are you already trying the 5.5 beta? The way we do wait() 
>> has changed considerably in 5.5, so it might be worth testing the beta to see 
>> if the problem also happens.
>> 
>> -- 
>> Thiago Macieira - thiago.macieira (AT) intel.com <http://intel.com/>
>>  Software Architect - Intel Open Source Technology Center
>> 
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org <mailto:Interest at qt-project.org>
>> http://lists.qt-project.org/mailman/listinfo/interest <http://lists.qt-project.org/mailman/listinfo/interest>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150519/86fec7c7/attachment.html>


More information about the Interest mailing list