]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[cmdline] Allow "sleep" command to be interrupted
authorMichael Brown <mcb30@ipxe.org>
Mon, 24 Oct 2011 14:52:57 +0000 (15:52 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 24 Oct 2011 14:52:57 +0000 (15:52 +0100)
Allow Ctrl-C to be used to abort a "sleep" command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/exec.c

index bcd990e099e596a28e865314bc833e368ff35f99..49261194d8975ac42ec5efa4d1ca5816d46959a2 100644 (file)
@@ -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;
 }