I am writing a Qt app to compile and run C++ files. I don't know how can I check for runtime errors such as segmentation fault after the process has been started. I tried using error() signal for reporting runtime error, but it doesn't tell anything about segmentation fault.
//connected to error() signal
void Tester::onError(QProcess::ProcessError e)
{
switch(e) {
case QProcess::Crashed:
case QProcess::WriteError:
case QProcess::ReadError:
case QProcess::UnknownError:
QMessageBox::information(NULL, "Run status", "Runtime error",
QMessageBox::Ok | QMessageBox::Default);
break;
default:
break;
}
}
This is the file I am testing it with-
#include <iostream>
int main() {
int *p = NULL;
*p = 1; //segmentation fault
std::cout << *p;
return 0;
}
When I test the file from the Qt app, the new process runs for about 15-20 seconds and then finished() signal is emitted, with a weird exit code and a message box saying "runtime error". How can I detect that there had been a segmentation fault in the new QProcess so that I can display it to the user?
I am working on Windows 7.