Discussion:
[Interest] Difference between QProcess::execute() and QProcess::start()
Joachim Langenbach
2015-09-15 19:25:24 UTC
Permalink
Good evening,

I have a php webservice and a Qt client. To test the webservice I use the php
build in webserver. Therefore my idea was to use the build in php webserver
also to serve the webservice instance during the Qt client tests. Todo so, I
tried to start the webserver with help of QProcess. But with QProcess::start()
the webserver produces very strange faults and with QProcess::execute(), it
works.

Since there is no difference mentioned in the documentation between those to
functions, I'd like to ask, if you have a idea what is going on here.

I attached a small example with both methods executing /usr/bin/php

Kind regards,

Joachim Langenbach
Lorenz Haas
2015-09-16 04:42:05 UTC
Permalink
Post by Joachim Langenbach
But with QProcess::start()
the webserver produces very strange faults and with QProcess::execute(), it
works.
Since there is no difference mentioned in the documentation between those to
functions, I'd like to ask, if you have a idea what is going on here.
From the docs
"int QProcess::execute(const QString & command)

Starts the program command in a new process, waits for it to finish, and
then returns the exit code."

==> synchronous call


"void QProcess::start(const QString & program, const QStringList &
arguments, OpenMode mode = ReadWrite)

Note: Processes are started asynchronously, which means the started()
and error() signals may be delayed. Call waitForStarted() to make sure
the process has started (or has failed to start) and those signals have
been emitted."

==> *a*synchronous call


I think that's *a* big difference :)


Cheers
Lorenz
Joachim Langenbach
2015-09-17 19:14:15 UTC
Permalink
Good evening Lorenz,
Post by Lorenz Haas
==> synchronous call
"void QProcess::start(const QString & program, const QStringList &
arguments, OpenMode mode = ReadWrite)
Note: Processes are started asynchronously, which means the started()
and error() signals may be delayed. Call waitForStarted() to make sure
the process has started (or has failed to start) and those signals have
been emitted."
==> *a*synchronous call
I think that's *a* big difference :)
Yeah, you're right! Actually I knew this difference alrady and because of the
asynchronous call I want to use the start() method, but it isn't working with
the php executable, whereas the execute() method does. My guess is a different
system environment or a problem with STDOUT, STDIN or STDERR.

But I want to proof it, that's why I asked for the differences.

Regards,

Joachim
Thiago Macieira
2015-09-17 21:28:58 UTC
Permalink
Post by Joachim Langenbach
Yeah, you're right! Actually I knew this difference alrady and because of
the asynchronous call I want to use the start() method, but it isn't
working with the php executable, whereas the execute() method does. My
guess is a different system environment or a problem with STDOUT, STDIN or
STDERR.
But I want to proof it, that's why I asked for the differences.
int QProcess::execute(const QString &program, const QStringList &arguments)
{
QProcess process;
process.setReadChannelMode(ForwardedChannels);
process.start(program, arguments);
if (!process.waitForFinished(-1) || process.error() == FailedToStart)
return -2;
return process.exitStatus() == QProcess::NormalExit ? process.exitCode() :
-1;
}

Any and all differences are there.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
Joachim Langenbach
2015-09-20 16:16:50 UTC
Permalink
Hallo Thiago,

thanks for your hint. Actually i figured out, that the
QProcess::waitForStarted() function isn't working with the php built in
webserver. The PHP process is marked as started, but isn't up at that time. I
use a different method now to check whether it is running or not and everything
is fine now.

Regards,

Joachim
Thiago Macieira
2015-09-20 18:02:00 UTC
Permalink
Post by Joachim Langenbach
thanks for your hint. Actually i figured out, that the
QProcess::waitForStarted() function isn't working with the php built in
webserver. The PHP process is marked as started, but isn't up at that time.
I use a different method now to check whether it is running or not and
everything is fine now.
If waitForStarted() failed, it means one of two system calls failed:

chdir()
execve()

Check whether you passed the correct path to QProcess. That's basically the
only thing that can cause a process to fail to start. Check the errorString()
value too.

If that isn't the case, run your application under strace -ff and check at the
beginning of the second file what it tried to do and failed.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
sun.hw
2015-09-16 05:15:22 UTC
Permalink
Hi guys,

I have an issue to hide a quick item and show another. When I use new QQmlComponent( engine, qml_file_name, rootObject ),
blocking happens sometimes. And most of the time it run well with the same qml_file_name . Why?
Has anybody met such a problem?

Kind regards,

Albert Sun


---------------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s)
is intended only for the use of the intended recipient and may be confidential and/or privileged of
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is
not the intended recipient, unauthorized use, forwarding, printing, storing, disclosure or copying
is strictly prohibited, and may be unlawful.If you have received this communication in error,please
immediately notify the sender by return e-mail, and delete the original message and all copies from
your system. Thank you.
---------------------------------------------------------------------------------------------------
Loading...