david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[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>
This commit is contained in:
Michael Brown 2011-10-24 15:52:57 +01:00
parent f177a6f09f
commit 59e4c37741
1 changed files with 8 additions and 1 deletions

View 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;
}