Shell: Handle aborting loops better
It's easy to get stuck in an infinite loop in the hush shell:

while true; do sleep 1; done

The 'sleep' command will check for ctrl-c with the ctrlc() function. This
will abort the sleep command. Hush then checks for ctrl-c again in the
loop. The ctrl-c in the buffer has already been eaten by the sleep
command, so the loop will continue.

With this patch we remember the presence of a ctrl-c character in a
variable instead of checking for a new character each time. The
variable must be resetted explicitly by calling ctrlc_handled() which
will be called by the shell in the outer loop.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
1 parent ea569a0 commit c5f991d2ad8ea2d872fad64dee2fd660bb0a1b20
@Sascha Hauer Sascha Hauer authored on 25 Feb 2019
Showing 5 changed files
View
arch/sandbox/os/common.c
View
common/console.c
View
common/hush.c
View
common/parser.c
View
include/common.h