Skip to content

Commit

Permalink
[cmdline] Allow "sleep" command to be interrupted
Browse files Browse the repository at this point in the history
Allow Ctrl-C to be used to abort a "sleep" command.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Oct 24, 2011
1 parent f177a6f commit 59e4c37
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core/exec.c
Expand Up @@ -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>

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 59e4c37

Please sign in to comment.