Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Regular Contributor
aesteral
Posts: 51
Registered: ‎02-24-2012
My Device: Blackberry Whatever

QProcess does not launch processes

Hello!

 

I have a .bar-file with several executables placed in native/bin directory. I would like to launch them when needed from my main Qt application (specified as entry point).

 

QString program = "app/native/bin/test";
QStringList arguments;

QProcess *myProcess = new QProcess(parent);
myProcess->setStandardErrorFile("tmp/stderr");

myProcess->setStandardOutputFile("tmp/stdout");
myProcess->start(program, arguments);
myProcess->waitForStarted();

qDebug() << "PROC: " << myProcess->state() << " " << myProcess->error();

 

I get empty tmp/stderr and tmp/stdout and PROC: 0 0 in my logs/log file. So it seems to me, that QProcess does not start processes. Is it even possbile in sandbox?

Regular Contributor
aesteral
Posts: 51
Registered: ‎02-24-2012
My Device: Blackberry Whatever

Re: QProcess does not launch processes

[ Edited ]

I've tried to use execv() call to spawn a process. It've returned a -1 return value which indicates a failure and have set the errno variable to EINVAL (22). Blackberry C library documentation does not mention EINVAL as a possible errno for this call: https://bdsc.webapps.blackberry.com/native/reference/com.qnx.doc.neutrino.lib_ref/topic/e/execv.html. What am I missing here? What does EINVAL mean in this context?

Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: QProcess does not launch processes

I suspect QProcess uses fork() and it does not work on PlayBook for multithreaded applications (see Caveats here https://bdsc.webapps.blackberry.com/native/reference/com.qnx.doc.neutrino.lib_ref/topic/f/fork.html) and any QT app is multithreaded.

Regular Contributor
aesteral
Posts: 51
Registered: ‎02-24-2012
My Device: Blackberry Whatever

Re: QProcess does not launch processes

Well, that certainly can be the issue. I can successfully spawn other processes using a popen() call which uses spawnlp() call.

Developer
dkonigs
Posts: 256
Registered: ‎07-25-2008
My Device: Bold 9900

Re: QProcess does not launch processes

Just a tad of an update...  I looked at the Qt 4.8 source code, and QProcess is supposed to use spawn() on QNX.  However, one of the inheritance struct flags its passing to spawn() (SPAWN_SETSID) seems to prevent the call from executing successfully.  If you call spawn() without that flag, it seems to work just fine.

 

So either we need a workaround for this, or we just have to spawn() and I/O redirect from external processes the hard way.