Added signal catching of SIGHUP and SIGTERM to cause simulator STOP. This will facilitate running a simulator as a 'service' on *nix platforms, given a sufficiently flexible simulator .ini file.
This commit is contained in:
parent
e70278eabf
commit
312bc9a967
1 changed files with 15 additions and 3 deletions
18
scp.c
18
scp.c
|
@ -2976,9 +2976,6 @@ for (i = 1; (dptr = sim_devices[i]) != NULL; i++) { /* reposition all */
|
|||
}
|
||||
}
|
||||
stop_cpu = 0;
|
||||
if (signal (SIGINT, int_handler) == SIG_ERR) { /* set WRU */
|
||||
return SCPE_SIGERR;
|
||||
}
|
||||
if (sim_ttrun () != SCPE_OK) { /* set console mode */
|
||||
sim_ttcmd ();
|
||||
return SCPE_TTYERR;
|
||||
|
@ -2987,6 +2984,17 @@ if ((r = sim_check_console (30)) != SCPE_OK) { /* check console, error?
|
|||
sim_ttcmd ();
|
||||
return r;
|
||||
}
|
||||
if (signal (SIGINT, int_handler) == SIG_ERR) { /* set WRU */
|
||||
return SCPE_SIGERR;
|
||||
}
|
||||
#ifdef SIGHUP
|
||||
if (signal (SIGHUP, int_handler) == SIG_ERR) { /* set WRU */
|
||||
return SCPE_SIGERR;
|
||||
}
|
||||
#endif
|
||||
if (signal (SIGTERM, int_handler) == SIG_ERR) { /* set WRU */
|
||||
return SCPE_SIGERR;
|
||||
}
|
||||
if (sim_step) /* set step timer */
|
||||
sim_activate (&sim_step_unit, sim_step);
|
||||
sim_throt_sched (); /* set throttle */
|
||||
|
@ -2998,6 +3006,10 @@ r = sim_instr();
|
|||
sim_is_running = 0; /* flag idle */
|
||||
sim_ttcmd (); /* restore console */
|
||||
signal (SIGINT, SIG_DFL); /* cancel WRU */
|
||||
#ifdef SIGHUP
|
||||
signal (SIGHUP, SIG_DFL); /* cancel WRU */
|
||||
#endif
|
||||
signal (SIGTERM, SIG_DFL); /* cancel WRU */
|
||||
if (sim_log) /* flush console log */
|
||||
fflush (sim_log);
|
||||
if (sim_deb) /* flush debug log */
|
||||
|
|
Loading…
Add table
Reference in a new issue