mirror of
https://github.com/simh/simh.git
synced 2026-01-11 23:52:58 +00:00
Added sim_ttisatty to support reasonable behaviour (i.e. avoid in infinite loop) in the main command input loop when EOF is detected and input is coming from a file (or a null device: /dev/null or NUL:) This may happen when a simulator is running in a background process.
This commit is contained in:
parent
de5997608d
commit
01369c13da
5
scp.c
5
scp.c
@ -778,8 +778,9 @@ while (stat != SCPE_EXIT) { /* in case exit */
|
||||
cptr = (*sim_vm_read) (cbuf, CBUFSIZE, stdin);
|
||||
}
|
||||
else cptr = read_line_p ("sim> ", cbuf, CBUFSIZE, stdin);/* read with prmopt*/
|
||||
if (cptr == NULL) /* ignore EOF */
|
||||
continue;
|
||||
if (cptr == NULL) /* EOF? */
|
||||
if (sim_ttisatty()) continue; /* ignore tty EOF */
|
||||
else break; /* otherwise exit */
|
||||
if (*cptr == 0) /* ignore blank */
|
||||
continue;
|
||||
sub_args (cbuf, gbuf, CBUFSIZE, argv);
|
||||
|
||||
@ -23,6 +23,12 @@
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from Robert M Supnik.
|
||||
|
||||
07-Dec-11 MP Added sim_ttisatty to support reasonable behaviour (i.e.
|
||||
avoid in infinite loop) in the main command input
|
||||
loop when EOF is detected and input is coming from
|
||||
a file (or a null device: /dev/null or NUL:) This may
|
||||
happen when a simulator is running in a background
|
||||
process.
|
||||
17-Apr-11 MP Cleaned up to support running in a background/detached
|
||||
process
|
||||
20-Jan-11 MP Fixed support for BREAK key on Windows to account
|
||||
@ -98,6 +104,7 @@
|
||||
sim_ttrun - called to put terminal into run state
|
||||
sim_ttcmd - called to return terminal to command state
|
||||
sim_ttclose - called once before the simulator exits
|
||||
sim_ttisatty - called to determine if running interactively
|
||||
sim_os_poll_kbd - poll for keyboard input
|
||||
sim_os_putchar - output character to console
|
||||
|
||||
@ -867,6 +874,11 @@ t_stat sim_ttclose (void)
|
||||
return sim_ttcmd ();
|
||||
}
|
||||
|
||||
t_bool sim_ttisatty (void)
|
||||
{
|
||||
return isatty (fileno (stdin));
|
||||
}
|
||||
|
||||
t_stat sim_os_poll_kbd (void)
|
||||
{
|
||||
unsigned int status, term[2];
|
||||
@ -986,6 +998,13 @@ t_stat sim_ttclose (void)
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
t_bool sim_ttisatty (void)
|
||||
{
|
||||
DWORD Mode;
|
||||
|
||||
return (std_input) && (std_input != INVALID_HANDLE_VALUE) && GetConsoleMode (std_input, &Mode);
|
||||
}
|
||||
|
||||
t_stat sim_os_poll_kbd (void)
|
||||
{
|
||||
int c = -1;
|
||||
@ -1063,6 +1082,11 @@ t_stat sim_ttclose (void)
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
t_bool sim_ttisatty (void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
t_stat sim_os_poll_kbd (void)
|
||||
{
|
||||
int c;
|
||||
@ -1259,6 +1283,11 @@ t_stat sim_ttclose (void)
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
t_bool sim_ttisatty (void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
t_stat sim_os_poll_kbd (void)
|
||||
{
|
||||
int c;
|
||||
@ -1355,6 +1384,11 @@ t_stat sim_ttclose (void)
|
||||
return sim_ttcmd ();
|
||||
}
|
||||
|
||||
t_bool sim_ttisatty (void)
|
||||
{
|
||||
return isatty (0);
|
||||
}
|
||||
|
||||
t_stat sim_os_poll_kbd (void)
|
||||
{
|
||||
int status;
|
||||
@ -1462,6 +1496,11 @@ t_stat sim_ttclose (void)
|
||||
return sim_ttcmd ();
|
||||
}
|
||||
|
||||
t_bool sim_ttisatty(void)
|
||||
{
|
||||
return isatty (fileno (stdin));
|
||||
}
|
||||
|
||||
t_stat sim_os_poll_kbd (void)
|
||||
{
|
||||
int status;
|
||||
|
||||
@ -83,6 +83,7 @@ t_stat sim_ttinit (void);
|
||||
t_stat sim_ttrun (void);
|
||||
t_stat sim_ttcmd (void);
|
||||
t_stat sim_ttclose (void);
|
||||
t_bool sim_ttisatty(void);
|
||||
t_stat sim_os_poll_kbd (void);
|
||||
t_stat sim_os_putchar (int32 out);
|
||||
int32 sim_tt_inpcvt (int32 c, uint32 mode);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user