Skip to content

Commit

Permalink
Be clearer about return value from router process (#99)
Browse files Browse the repository at this point in the history
Signed-off-by: Yadunund <[email protected]>
  • Loading branch information
Yadunund authored Jan 23, 2024
1 parent 44ec46f commit d49f976
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rmw_zenoh_cpp/apps/init_rmw_zenoh_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#include <stdlib.h>
#include <sys/wait.h>

#include <iostream>
#include <string>
Expand All @@ -33,9 +34,15 @@ int Main(int, char **)
// Execute zenohd command
const std::string zenohd_cmd = "zenohd -c " + zenoh_router_config_path;
const int ret = system(zenohd_cmd.c_str());
if (ret != 0) {
std::cerr << "Failed to run zenoh router: " << zenohd_cmd << std::endl;
if (ret < 0) {
std::cerr << "Error running zenoh router via command: " << zenohd_cmd << std::endl;
return ret;
} else {
if (WIFEXITED(ret)) {
std::cout << "Zenoh router exited normally." << std::endl;
} else {
std::cout << "Zenoh router exited abnormally with error code [" << ret << "]" << std::endl;
}
}
return 0;
}
Expand Down

0 comments on commit d49f976

Please sign in to comment.