mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 11:43:33 +08:00
segway_main: avoid using exit()
This commit is contained in:
@@ -78,7 +78,6 @@ usage(const char *reason)
|
||||
}
|
||||
|
||||
fprintf(stderr, "usage: segway {start|stop|status} [-p <additional params>]\n\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,6 +93,7 @@ int segway_main(int argc, char *argv[])
|
||||
|
||||
if (argc < 2) {
|
||||
usage("missing command");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "start")) {
|
||||
@@ -101,7 +101,7 @@ int segway_main(int argc, char *argv[])
|
||||
if (thread_running) {
|
||||
warnx("already running");
|
||||
/* this is not an error */
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
thread_should_exit = false;
|
||||
@@ -112,12 +112,12 @@ int segway_main(int argc, char *argv[])
|
||||
5120,
|
||||
segway_thread_main,
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)nullptr);
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "stop")) {
|
||||
thread_should_exit = true;
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "status")) {
|
||||
@@ -128,11 +128,11 @@ int segway_main(int argc, char *argv[])
|
||||
warnx("not started");
|
||||
}
|
||||
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
usage("unrecognized command");
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int segway_thread_main(int argc, char *argv[])
|
||||
|
||||
Reference in New Issue
Block a user