rover_steering_control: avoid using exit()

This commit is contained in:
Beat Küng
2018-08-31 10:26:06 +02:00
parent 258f7a7ff8
commit 50cdb01141
+6 -6
View File
@@ -395,7 +395,6 @@ usage(const char *reason)
}
fprintf(stderr, "usage: rover_steering_control {start|stop|status}\n\n");
exit(1);
}
/**
@@ -410,6 +409,7 @@ int rover_steering_control_main(int argc, char *argv[])
{
if (argc < 2) {
usage("missing command");
return 1;
}
if (!strcmp(argv[1], "start")) {
@@ -417,7 +417,7 @@ int rover_steering_control_main(int argc, char *argv[])
if (thread_running) {
warnx("running");
/* this is not an error */
exit(0);
return 0;
}
thread_should_exit = false;
@@ -428,12 +428,12 @@ int rover_steering_control_main(int argc, char *argv[])
rover_steering_control_thread_main,
(argv) ? (char *const *)&argv[2] : (char *const *)nullptr);
thread_running = true;
exit(0);
return 0;
}
if (!strcmp(argv[1], "stop")) {
thread_should_exit = true;
exit(0);
return 0;
}
if (!strcmp(argv[1], "status")) {
@@ -444,11 +444,11 @@ int rover_steering_control_main(int argc, char *argv[])
warnx("not started");
}
exit(0);
return 0;
}
usage("unrecognized command");
exit(1);
return 1;
}