segway_main: avoid using exit()

This commit is contained in:
Beat Küng
2018-08-31 18:11:58 +02:00
parent 0dc8eeb118
commit 9193312bd0
+6 -6
View File
@@ -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[])