Skip to content
Snippets Groups Projects
Commit 62cecc94 authored by Lucas Jenss's avatar Lucas Jenss
Browse files

Do not try to continue reading shell commands if input source is closed

In RIOT native, sending CTRL+D to a shell started using shell_run would resulted in and
endless prompt loop. I've been unable to trigger such a behaviour
on actual hardware using a UART connection, but calling `pm_off` seemed
like a better alternative than having an `#ifdef BOARD_NATIVE`.

Fixes #9946
parent 99e75948
Branches
No related tags found
No related merge requests found
......@@ -69,10 +69,8 @@ typedef struct shell_command_t {
* @param[in] commands ptr to array of command structs
* @param[in] line_buf Buffer that will be used for reading a line
* @param[in] len nr of bytes that fit in line_buf
*
* @returns This function does not return.
*/
void shell_run(const shell_command_t *commands, char *line_buf, int len) NORETURN;
void shell_run(const shell_command_t *commands, char *line_buf, int len);
#ifdef __cplusplus
}
......
......@@ -228,7 +228,7 @@ static int readline(char *buf, size_t size)
int c = getchar();
if (c < 0) {
return 1;
return EOF;
}
/* We allow Unix linebreaks (\n), DOS linebreaks (\r\n), and Mac linebreaks (\r). */
......@@ -287,6 +287,10 @@ void shell_run(const shell_command_t *shell_commands, char *line_buf, int len)
while (1) {
int res = readline(line_buf, len);
if (res == EOF) {
break;
}
if (!res) {
handle_input_line(shell_commands, line_buf);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment