Browse Source

[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>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
59e4c37741
1 changed files with 8 additions and 1 deletions
  1. 8
    1
      src/core/exec.c

+ 8
- 1
src/core/exec.c View File

@@ -31,6 +31,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
31 31
 #include <ipxe/command.h>
32 32
 #include <ipxe/parseopt.h>
33 33
 #include <ipxe/settings.h>
34
+#include <ipxe/console.h>
35
+#include <ipxe/keys.h>
36
+#include <ipxe/process.h>
34 37
 #include <ipxe/nap.h>
35 38
 #include <ipxe/shell.h>
36 39
 
@@ -564,8 +567,12 @@ static int sleep_exec ( int argc, char **argv ) {
564 567
 	/* Delay for specified number of seconds */
565 568
 	start = currticks();
566 569
 	delay = ( seconds * TICKS_PER_SEC );
567
-	while ( ( currticks() - start ) <= delay )
570
+	while ( ( currticks() - start ) <= delay ) {
571
+		step();
572
+		if ( iskey() && ( getchar() == CTRL_C ) )
573
+			return -ECANCELED;
568 574
 		cpu_nap();
575
+	}
569 576
 
570 577
 	return 0;
571 578
 }

Loading…
Cancel
Save