SCP: Make SLEEP command interruptable with SIGINT
This commit is contained in:
parent
e2944eb6e0
commit
733ac0d982
2 changed files with 9 additions and 3 deletions
BIN
doc/simh_doc.doc
BIN
doc/simh_doc.doc
Binary file not shown.
12
scp.c
12
scp.c
|
@ -1782,7 +1782,8 @@ ASSERT failure have several different actions:
|
|||
" Pause for NUMBER seconds. SUFFIX may be 's' for seconds (the default),\n"
|
||||
" 'm' for minutes, 'h' for hours or 'd' for days. NUMBER may be an\n"
|
||||
" arbitrary floating point number. Given two or more arguments, pause\n"
|
||||
" for the amount of time specified by the sum of their values.\n\n"
|
||||
" for the amount of time specified by the sum of their values.\n"
|
||||
" NOTE: A SLEEP command is interruptable with SIGINT (^C).\n\n"
|
||||
/***************** 80 character line width template *************************/
|
||||
#define HLP_ASSERT "*Commands Executing_Command_Files Testing_Simulator_State"
|
||||
#define HLP_IF "*Commands Executing_Command_Files Testing_Simulator_State"
|
||||
|
@ -3961,6 +3962,8 @@ t_stat sleep_cmd (int32 flag, CONST char *cptr)
|
|||
char *tptr;
|
||||
double wait;
|
||||
|
||||
stop_cpu = 0;
|
||||
signal (SIGINT, int_handler);
|
||||
while (*cptr) {
|
||||
wait = strtod (cptr, &tptr);
|
||||
switch (*tptr) {
|
||||
|
@ -3988,15 +3991,18 @@ while (*cptr) {
|
|||
wait *= (24.0*60.0*60.0);
|
||||
break;
|
||||
default:
|
||||
signal (SIGINT, SIG_DFL); /* cancel WRU */
|
||||
return sim_messagef (SCPE_ARG, "Invalid Sleep unit '%c'\n", *cptr);
|
||||
}
|
||||
wait *= 1000.0; /* Convert to Milliseconds */
|
||||
cptr = tptr;
|
||||
while (wait > 1000.0)
|
||||
while ((wait > 1000.0) && (!stop_cpu))
|
||||
wait -= sim_os_ms_sleep (1000);
|
||||
if (wait > 0.0)
|
||||
if ((wait > 0.0) && (!stop_cpu))
|
||||
sim_os_ms_sleep ((unsigned)wait);
|
||||
}
|
||||
signal (SIGINT, SIG_DFL); /* cancel WRU */
|
||||
stop_cpu = 0;
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue