From 868039416797df735ca5ee8afc10fb47a27a2a14 Mon Sep 17 00:00:00 2001 From: MadnessASAP Date: Thu, 12 Mar 2020 15:10:40 -0700 Subject: [PATCH] Break the input loop on error or EOF --- examples/system/console/main/console_example_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/system/console/main/console_example_main.c b/examples/system/console/main/console_example_main.c index 0caae21279..697a0345a8 100644 --- a/examples/system/console/main/console_example_main.c +++ b/examples/system/console/main/console_example_main.c @@ -170,8 +170,8 @@ void app_main(void) * The line is returned when ENTER is pressed. */ char* line = linenoise(prompt); - if (line == NULL) { /* Ignore empty lines */ - continue; + if (line == NULL) { /* Break on EOF or error */ + break; } /* Add the command to the history */ linenoiseHistoryAdd(line); @@ -195,4 +195,8 @@ void app_main(void) /* linenoise allocates line buffer on the heap, so need to free it */ linenoiseFree(line); } + + ESP_LOGE(TAG, "Error or end-of-input, terminating console"); + esp_console_deinit(); + vTaskDelete(NULL); /* terminate app_main */ }