PDA

View Full Version : Problem executing process



EricF
23rd January 2008, 14:11
I'm trying to execute a third party process using QProcess and it's almost working but fails to write the output file.

I connected my main process to signal error, readyReadStandardOutput and readyReadStandardError and I've received all of them and it helped me debug my command line but my process should output a file and the file isn't showing.

I searched a bit on here and had the idea to start the process detached and then it works but it pops a terminal which I don't want to see.

Considering that the only change I made was to start it detached as opposed to a normal start, what could be the problem ? I'd guess that the processes don't have the same right but I'm not sure.

In anyway, I'm sick of battling with this problem, help :eek:

wysota
23rd January 2008, 15:33
Can we see the code used to spawn the process? Did you check what is the current working directory when you spawn the process?

EricF
23rd January 2008, 15:45
Here's the code:


QString dotExec("dot");

// Then set arguments
QStringList args;
args << QString("-T%1").arg(extension);
args << QString("-o%1").arg(filename);
args << QString("%1").arg(newFilename);

// Finally call the process
mProcess = new QProcess;
connect( mProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(OnProcessError(QProcess::ProcessError)) );
connect( mProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(OnStandardOutput()) );
connect( mProcess, SIGNAL(readyReadStandardError()), this, SLOT(OnErrorOutput()) );
mProcess->startDetached( dotExec, args );

bool processReturn = mProcess->waitForFinished();

delete mProcess;
mProcess = NULL;

return processReturn;


Of course waitForFinished returns false when use with startDetached() but works okay when calling start(). Right now, I'm using full path so I don't think working directory has an impact because the input file can be opened no matter what starting technique I use. It's just the output file that doesn't get written.

wysota
24th January 2008, 00:29
Could you add the following statement somewhere after filling args and show us its output?


qDebug() << args;

You'll need to #include <QtDebug> for that to work of course.

Also make sure the process indeed gets started...

EricF
25th January 2008, 16:04
Here's the output:

("-Tpng", "-oc:\temp\graph.png", "c:\temp\graph.dot")

as I said, if I start it detached it works perfect except for the console popping up. So I don't think my args could be wrong.

Also, when I start it normally(using start()), I receive the signal finished with ExitStatus = NormalExit. So I figured the process gets started.