diff options
author | Michael Brown | 2011-10-24 16:52:57 +0200 |
---|---|---|
committer | Michael Brown | 2011-10-24 16:52:57 +0200 |
commit | 59e4c377419a9489e190496059d59fed16502e46 (patch) | |
tree | 6c75efe4223c8c06a0a22414947b4a15158d98f8 /src/core/exec.c | |
parent | [cmdline] Fix up "sleep" argument parsing (diff) | |
download | ipxe-59e4c377419a9489e190496059d59fed16502e46.tar.gz ipxe-59e4c377419a9489e190496059d59fed16502e46.tar.xz ipxe-59e4c377419a9489e190496059d59fed16502e46.zip |
[cmdline] Allow "sleep" command to be interrupted
Allow Ctrl-C to be used to abort a "sleep" command.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/exec.c')
-rw-r--r-- | src/core/exec.c | 9 |
1 files changed, 8 insertions, 1 deletions
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 <ipxe/command.h> #include <ipxe/parseopt.h> #include <ipxe/settings.h> +#include <ipxe/console.h> +#include <ipxe/keys.h> +#include <ipxe/process.h> #include <ipxe/nap.h> #include <ipxe/shell.h> @@ -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; } |