PDA

View Full Version : QProcess not working correctly



m_bishop
25th May 2013, 01:25
I am trying to run 100 instances of a program in the background. I get to 51 and my Qt app locks up with "QProcess : Destroyed while process is still running."

So I am thinking that maybe I am running into some sort of linux max limit of something (memory, sockets, whatever). So I create a bash script that creates 100 instances of my app and puts each one in the background with no problem.

And now I am stuck.

Here is how I am calling it:



{
QProcess* process = new QProcess();

QString program = "my_program cmdline_option_1 cmdline_option_2";
process->start(program);
}


and this is called from a clicked() event.

Added after 4 minutes:

Maybe I should be using:



process->startDetached(program);


Added after 30 minutes:

Nothing to see here...move along......

saman_artorious
25th May 2013, 09:54
So I am thinking that maybe I am running into some sort of linux max limit of something (memory, sockets, whatever). So I create a bash script that creates 100 instances of my app and puts each one in the background with no problem.

MAXIMUM NUMBER OF PROCESSES

cat /proc/sys/kernel/pid_max

besides, start() runs the process if has not already been initiated.
you may also check for standard error when writing your code, use the QProcess members like:


QProcess::ProcessError Error = Prozess->error ();

http://qt-project.org/doc/qt-4.8/qprocess.html#startDetached

m_bishop
28th May 2013, 17:36
Ok, so I use the startDetached() and I can now create 68 instances, but no more than that. I get the 'QProcess: Destroyed while process is still running."



cat /proc/sys/kernel/pid_max

32768


I don't even have 300 PIDs when looking at 'top' or 'ps'.

When I start my apps with startDetrached() I am creating a custom widget for each one that has 6 slots, but I think that isn't an issue - yet.

Any idea what is going on?

Added after 1 21 minutes:

I tried:



{
QProcess* process = new QProcess();

QString program = "my_program cmdline_option_1 cmdline_option_2";
process->startDetached(program);
process->terminate();
}


And I still can only run 68 instances of my app. It always does 'QProcess: Destroyed while process is still running.'