mirror of
https://github.com/ipxe/ipxe
synced 2026-02-14 02:31:26 +03:00
[libc] Make sleep() interruptible
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -36,10 +36,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#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>
|
||||
|
||||
/** @file
|
||||
@@ -573,8 +569,6 @@ static struct command_descriptor sleep_cmd =
|
||||
static int sleep_exec ( int argc, char **argv ) {
|
||||
struct sleep_options opts;
|
||||
unsigned int seconds;
|
||||
unsigned long start;
|
||||
unsigned long delay;
|
||||
int rc;
|
||||
|
||||
/* Parse options */
|
||||
@@ -586,14 +580,8 @@ static int sleep_exec ( int argc, char **argv ) {
|
||||
return rc;
|
||||
|
||||
/* Delay for specified number of seconds */
|
||||
start = currticks();
|
||||
delay = ( seconds * TICKS_PER_SEC );
|
||||
while ( ( currticks() - start ) <= delay ) {
|
||||
step();
|
||||
if ( iskey() && ( getchar() == CTRL_C ) )
|
||||
return -ECANCELED;
|
||||
cpu_nap();
|
||||
}
|
||||
if ( sleep ( seconds ) != 0 )
|
||||
return -ECANCELED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user