[Interest] The right way of using QProcess

Nuno Santos nunosantos at imaginando.pt
Tue May 19 17:12:20 CEST 2015


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
+351 91 621 69 62

> On 19 May 2015, at 15:58, Thiago Macieira <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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150519/36792dbe/attachment.html>


More information about the Interest mailing list