[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:
parent
f177a6f09f
commit
59e4c37741
@ -31,6 +31,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||||||
#include <ipxe/command.h>
|
#include <ipxe/command.h>
|
||||||
#include <ipxe/parseopt.h>
|
#include <ipxe/parseopt.h>
|
||||||
#include <ipxe/settings.h>
|
#include <ipxe/settings.h>
|
||||||
|
#include <ipxe/console.h>
|
||||||
|
#include <ipxe/keys.h>
|
||||||
|
#include <ipxe/process.h>
|
||||||
#include <ipxe/nap.h>
|
#include <ipxe/nap.h>
|
||||||
#include <ipxe/shell.h>
|
#include <ipxe/shell.h>
|
||||||
|
|
||||||
@ -564,8 +567,12 @@ static int sleep_exec ( int argc, char **argv ) {
|
|||||||
/* Delay for specified number of seconds */
|
/* Delay for specified number of seconds */
|
||||||
start = currticks();
|
start = currticks();
|
||||||
delay = ( seconds * TICKS_PER_SEC );
|
delay = ( seconds * TICKS_PER_SEC );
|
||||||
while ( ( currticks() - start ) <= delay )
|
while ( ( currticks() - start ) <= delay ) {
|
||||||
|
step();
|
||||||
|
if ( iskey() && ( getchar() == CTRL_C ) )
|
||||||
|
return -ECANCELED;
|
||||||
cpu_nap();
|
cpu_nap();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user