From 6ce5e1be49526b186cfade19d370642802c90123 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Mon, 25 Jan 2016 16:33:25 +0100 Subject: [PATCH] posix sitl: don't exit if a command fails --- src/platforms/posix/main.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/platforms/posix/main.cpp b/src/platforms/posix/main.cpp index 749feaa6a3..13343367fc 100644 --- a/src/platforms/posix/main.cpp +++ b/src/platforms/posix/main.cpp @@ -112,10 +112,16 @@ static void run_cmd(const vector &appargs, bool exit_on_fail) int retval = apps[command](i, (char **)arg); - if (exit_on_fail && retval) { - exit(retval); + if (retval) { + cout << "Command failed, returned " << retval << endl; + + if (exit_on_fail && retval) { + exit(retval); + } } + + } else if (command.compare("help") == 0) { list_builtins(); @@ -136,7 +142,7 @@ static void usage() { cout << "./mainapp [-d] [startup_config] -h" << std::endl; - cout << " -d - Optional flag to run the app in daemon mode and does not take listen for user input." << + cout << " -d - Optional flag to run the app in daemon mode and does not listen for user input." << std::endl; cout << " This is needed if mainapp is intended to be run as a upstart job on linux" << std::endl; cout << " - config file for starting/stopping px4 modules" << std::endl; @@ -215,6 +221,7 @@ int main(int argc, char **argv) if (infile.is_open()) { for (string line; getline(infile, line, '\n');) { + // TODO: this should be true but for that we have to check all startup files process_line(line, false); } @@ -308,7 +315,7 @@ int main(int argc, char **argv) } } - process_line(mystr, !daemon_mode); + process_line(mystr, false); mystr = ""; buf_ptr_read = buf_ptr_write; break;