I have a Qt application (non-GUI) running. I want to know the state in which my application exited so I can either restart it or mark it as completed successfully. Think of it as a simple shell script that wants to know this.
I'm using QCoreApplication::exit(errorCode)
to exit the application but I'm not sure how and where to read this value.
QCoreApplication::exit(errorCode)
exits the event loop with a return value of errorCode
.
int main(int argc, char**argv)
{
QCoreApplication a(argc, argv);
return a.exec();
}
...
a.exit(errorCode)
returns errorCode
from the application
If you are using bash as a shell you can find the exit code of the last application in $?
bash$ echo $?
0