PDA

View Full Version : QProcess exitStatus()



user_mail07
11th June 2008, 07:24
Hi Guys,
I have question about QProcess exitStatus() method. I am using QProcess to communicate with external program bash script. The bash script gives me return code of either 0,2 or 3. Now I want to test some conditions based on qprocess output. Once processExited() signal triggers it will connect to processDone() slot. Can QProcess returns the exit code of any digit other than 0. I noticed when my script gives me exit code of 2 or 3..I get crash as soon as processDone() get called. It looks like I can not verify the exit status of Qprocess other than using digit 0. I could have used readLineStdOut( ) to read output value but I dont want to get returned string value. How do I get exit status if return code from external program is numeric digit other than just 0.

I am using Qt3.



connect ( myProcess , SIGNAL ( processExited()) , this , SLOT ( processDone ( ) ) );

void MainWindow::processDone()
{
if ( myProcess->exitStatus() == 0)
{
qDebug () << "Program ran successfully";
}
if ( myProcess->exitStatus() == 2)
{
qDebug () << "Customized message";
}

if ( myProcess->exitStatus() == 3)
{
qDebug () << "Another text warning message";
}

}

wysota
11th June 2008, 07:38
If you get a crash, it is most likely caused by myProcess being an invalid pointer or something like that. Use a debugger to determine where exactly the crash occurs.

user_mail07
12th June 2008, 20:51
I solved my problem. Actually there was not a problem with Qprocess or exitStatus( ). exitStatus() can return any integer value. After checking the exitStatus of QProcess, I was not intializing the pointer to object properly.