apps/system/cu/cu_main.c: (1) Fix early exit.  getc(stdin) can return 0 the first time around.  (2) Set optind to zero.  getopt() was being left in a bad state, causing parsing errors on second use.  (3) Fix priority of cu_listen().  (4) Add suppor for -h.
@@ -290,7 +290,8 @@ int main(int argc, FAR char *argv[])
sa.sa_handler = sigint;
sigaction(SIGKILL, &sa, NULL);
- while ((option = getopt(argc, argv, "l:s:eor?")) != ERROR)
+ optind = 0; /* global that needs to be reset in FLAT mode */
+ while ((option = getopt(argc, argv, "l:s:ehor?")) != ERROR)
{
switch (option)
{
@@ -314,6 +315,7 @@ int main(int argc, FAR char *argv[])
rtscts = 0;
break;
+ case 'h':
case '?':
print_help();
return EXIT_SUCCESS;
@@ -357,6 +359,10 @@ int main(int argc, FAR char *argv[])
goto errout_with_fds;
}
+ /* Set priority of listener to configured value */
+
+ attr.priority = CONFIG_SYSTEM_CUTERM_PRIORITY;
+
ret = pthread_create(&g_cu.listener, &attr,
cu_listener, (pthread_addr_t)0);
if (ret != 0)
@@ -373,7 +379,7 @@ int main(int argc, FAR char *argv[])
if (ch <= 0)
{
- break;
+ continue;
}
if (start_of_line == 1 && ch == '~')
