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
 #include <ipxe/command.h>
31
 #include <ipxe/command.h>
32
 #include <ipxe/parseopt.h>
32
 #include <ipxe/parseopt.h>
33
 #include <ipxe/settings.h>
33
 #include <ipxe/settings.h>
34
+#include <ipxe/console.h>
35
+#include <ipxe/keys.h>
36
+#include <ipxe/process.h>
34
 #include <ipxe/nap.h>
37
 #include <ipxe/nap.h>
35
 #include <ipxe/shell.h>
38
 #include <ipxe/shell.h>
36
 
39
 
564
 	/* Delay for specified number of seconds */
567
 	/* Delay for specified number of seconds */
565
 	start = currticks();
568
 	start = currticks();
566
 	delay = ( seconds * TICKS_PER_SEC );
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
 		cpu_nap();
574
 		cpu_nap();
575
+	}
569
 
576
 
570
 	return 0;
577
 	return 0;
571
 }
578
 }

Loading…
Cancel
Save