From 59e4c377419a9489e190496059d59fed16502e46 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 24 Oct 2011 15:52:57 +0100 Subject: [PATCH] [cmdline] Allow "sleep" command to be interrupted Allow Ctrl-C to be used to abort a "sleep" command. Signed-off-by: Michael Brown --- src/core/exec.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/exec.c b/src/core/exec.c index bcd990e0..49261194 100644 --- a/src/core/exec.c +++ b/src/core/exec.c @@ -31,6 +31,9 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include #include #include +#include +#include +#include #include #include @@ -564,8 +567,12 @@ static int sleep_exec ( int argc, char **argv ) { /* Delay for specified number of seconds */ start = currticks(); delay = ( seconds * TICKS_PER_SEC ); - while ( ( currticks() - start ) <= delay ) + while ( ( currticks() - start ) <= delay ) { + step(); + if ( iskey() && ( getchar() == CTRL_C ) ) + return -ECANCELED; cpu_nap(); + } return 0; }