return proper exit code

This commit is contained in:
badaix 2017-03-04 13:17:44 +01:00
parent d4e03989fb
commit 833a1957fc
2 changed files with 6 additions and 3 deletions

View file

@ -70,6 +70,7 @@ int main (int argc, char **argv)
#ifdef MACOS #ifdef MACOS
#pragma message "Warning: the macOS support is experimental and might not be maintained" #pragma message "Warning: the macOS support is experimental and might not be maintained"
#endif #endif
int exitcode = EXIT_SUCCESS;
try try
{ {
string soundcard("default"); string soundcard("default");
@ -234,13 +235,14 @@ int main (int argc, char **argv)
catch (const std::exception& e) catch (const std::exception& e)
{ {
logS(kLogErr) << "Exception: " << e.what() << std::endl; logS(kLogErr) << "Exception: " << e.what() << std::endl;
exitcode = EXIT_FAILURE;
} }
logS(kLogNotice) << "daemon terminated." << endl; logS(kLogNotice) << "daemon terminated." << endl;
#ifdef HAS_DAEMON #ifdef HAS_DAEMON
daemonShutdown(); daemonShutdown();
#endif #endif
exit(EXIT_SUCCESS); exit(exitcode);
} }

View file

@ -50,6 +50,7 @@ int main(int argc, char* argv[])
#ifdef MACOS #ifdef MACOS
#pragma message "Warning: the macOS support is experimental and might not be maintained" #pragma message "Warning: the macOS support is experimental and might not be maintained"
#endif #endif
int exitcode = EXIT_SUCCESS;
try try
{ {
StreamServerSettings settings; StreamServerSettings settings;
@ -191,7 +192,6 @@ int main(int argc, char* argv[])
io_service.stop(); io_service.stop();
t.join(); t.join();
logO << "Stopping streamServer" << endl; logO << "Stopping streamServer" << endl;
streamServer->stop(); streamServer->stop();
logO << "done" << endl; logO << "done" << endl;
@ -199,12 +199,13 @@ int main(int argc, char* argv[])
catch (const std::exception& e) catch (const std::exception& e)
{ {
logS(kLogErr) << "Exception: " << e.what() << std::endl; logS(kLogErr) << "Exception: " << e.what() << std::endl;
exitcode = EXIT_FAILURE;
} }
logS(kLogNotice) << "daemon terminated." << endl; logS(kLogNotice) << "daemon terminated." << endl;
#ifdef HAS_DAEMON #ifdef HAS_DAEMON
daemonShutdown(); daemonShutdown();
#endif #endif
return 0; exit(exitcode);
} }