SCP: Report errno value when starting instruction execution fails

This commit is contained in:
Mark Pizzolato 2018-05-08 02:51:17 -07:00
parent 961f5e3285
commit 6ccbfc7381
2 changed files with 10 additions and 6 deletions

12
scp.c
View file

@ -7511,22 +7511,26 @@ for (i = 1; (dptr = sim_devices[i]) != NULL; i++) { /* reposition all */
} }
} }
if ((r = sim_ttrun ()) != SCPE_OK) { /* set console mode */ if ((r = sim_ttrun ()) != SCPE_OK) { /* set console mode */
r = sim_messagef (SCPE_TTYERR, "sim_ttrun() returned: %s - errno: %d - %s\n", sim_error_text (r), errno, strerror (errno));
sim_ttcmd (); sim_ttcmd ();
return sim_messagef (SCPE_TTYERR, "sim_ttrun() returned: %s\n", sim_error_text (r)); return r;
} }
if ((r = sim_check_console (30)) != SCPE_OK) { /* check console, error? */ if ((r = sim_check_console (30)) != SCPE_OK) { /* check console, error? */
r = sim_messagef (r, "sim_check_console () returned: %s - errno: %d - %s\n", sim_error_text (r), errno, strerror (errno));
sim_ttcmd (); sim_ttcmd ();
sim_messagef (r, "sim_check_console () returned: %s\n", sim_error_text (r)); return r;
} }
#ifdef SIGHUP #ifdef SIGHUP
if (signal (SIGHUP, int_handler) == SIG_ERR) { /* set WRU */ if (signal (SIGHUP, int_handler) == SIG_ERR) { /* set WRU */
r = sim_messagef (SCPE_SIGERR, "Can't establish SIGHUP: errno: %d - %s", errno, strerror (errno));
sim_ttcmd (); sim_ttcmd ();
return sim_messagef (SCPE_SIGERR, "Can't establish SIGHUP"); return r;
} }
#endif #endif
if (signal (SIGTERM, int_handler) == SIG_ERR) { /* set WRU */ if (signal (SIGTERM, int_handler) == SIG_ERR) { /* set WRU */
r = sim_messagef (SCPE_SIGERR, "Can't establish SIGTERM: errno: %d - %s", errno, strerror (errno));
sim_ttcmd (); sim_ttcmd ();
return sim_messagef (SCPE_SIGERR, "Can't establish SIGTERM"); return r;
} }
stop_cpu = FALSE; stop_cpu = FALSE;
sim_is_running = TRUE; /* flag running */ sim_is_running = TRUE; /* flag running */

View file

@ -3988,7 +3988,7 @@ runtty.c_cc[VINTR] = 0; /* OS X doesn't deliver
#else #else
runtty.c_cc[VINTR] = sim_int_char; /* in case changed */ runtty.c_cc[VINTR] = sim_int_char; /* in case changed */
#endif #endif
if (tcsetattr (0, TCSAFLUSH, &runtty) < 0) if (tcsetattr (fileno(stdin), TCSAFLUSH, &runtty) < 0)
return SCPE_TTIERR; return SCPE_TTIERR;
sim_os_set_thread_priority (PRIORITY_BELOW_NORMAL); /* try to lower pri */ sim_os_set_thread_priority (PRIORITY_BELOW_NORMAL); /* try to lower pri */
return SCPE_OK; return SCPE_OK;
@ -3999,7 +3999,7 @@ static t_stat sim_os_ttcmd (void)
if (!isatty (fileno (stdin))) /* skip if !tty */ if (!isatty (fileno (stdin))) /* skip if !tty */
return SCPE_OK; return SCPE_OK;
sim_os_set_thread_priority (PRIORITY_NORMAL); /* try to raise pri */ sim_os_set_thread_priority (PRIORITY_NORMAL); /* try to raise pri */
if (tcsetattr (0, TCSAFLUSH, &cmdtty) < 0) if (tcsetattr (fileno(stdin), TCSAFLUSH, &cmdtty) < 0)
return SCPE_TTIERR; return SCPE_TTIERR;
return SCPE_OK; return SCPE_OK;
} }