Better setting of the process exit status for fgfs and fgviewer
Some pieces of code such as fgMainInit() and, by cascading effect, fgInitHome(), were careful to return a meaningful value indicating success or error, however the main() function in src/Main/bootstrap.cxx ignored it royally so far. main() now returns: - EXIT_FAILURE if fgMainInit() or fgviewerMain() throws an exception; - whatever said function returns otherwise.
This commit is contained in:
parent
4b494a69bd
commit
cf318f1cc5
1 changed files with 7 additions and 6 deletions
|
@ -307,6 +307,7 @@ int main ( int argc, char **argv )
|
|||
setlocale(LC_COLLATE, "C");
|
||||
|
||||
bool fgviewer = flightgear::Options::checkForArg(argc, argv, "fgviewer");
|
||||
int exitStatus = EXIT_FAILURE;
|
||||
try {
|
||||
// http://code.google.com/p/flightgear-bugs/issues/detail?id=1231
|
||||
// ensure sglog is inited before atexit() is registered, so logging
|
||||
|
@ -323,10 +324,11 @@ int main ( int argc, char **argv )
|
|||
#endif
|
||||
std::set_terminate(fg_terminate);
|
||||
atexit(fgExitCleanup);
|
||||
if (fgviewer)
|
||||
fgviewerMain(argc, argv);
|
||||
else
|
||||
fgMainInit(argc, argv);
|
||||
if (fgviewer) {
|
||||
exitStatus = fgviewerMain(argc, argv);
|
||||
} else {
|
||||
exitStatus = fgMainInit(argc, argv);
|
||||
}
|
||||
|
||||
} catch (const sg_throwable &t) {
|
||||
std::string info;
|
||||
|
@ -334,7 +336,6 @@ int main ( int argc, char **argv )
|
|||
info = std::string("received from ") + t.getOrigin();
|
||||
flightgear::fatalMessageBoxWithoutExit(
|
||||
"Fatal exception", t.getFormattedMessage(), info);
|
||||
|
||||
} catch (const std::exception &e ) {
|
||||
flightgear::fatalMessageBoxWithoutExit("Fatal exception", e.what());
|
||||
} catch (const std::string &s) {
|
||||
|
@ -352,7 +353,7 @@ int main ( int argc, char **argv )
|
|||
crUninstall();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return exitStatus;
|
||||
}
|
||||
|
||||
// do some clean up on exit. Specifically we want to delete the sound-manager,
|
||||
|
|
Loading…
Reference in a new issue