SCP: Be sure to perform all library close activities whenever exiting

This commit is contained in:
Mark Pizzolato 2020-11-26 04:24:55 -08:00
parent 6a249c6246
commit 5cc86e2440

26
scp.c
View file

@ -2797,15 +2797,15 @@ if ((stat = sim_ttinit ()) != SCPE_OK) {
sim_error_text (stat));
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
sim_exit_status = EXIT_FAILURE;
goto cleanup_and_exit;
}
if ((sim_eval = (t_value *) calloc (sim_emax, sizeof (t_value))) == NULL) {
fprintf (stderr, "Unable to allocate examine buffer\n");
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
sim_exit_status = EXIT_FAILURE;
goto cleanup_and_exit;
};
if (sim_dflt_dev == NULL) /* if no default */
sim_dflt_dev = sim_devices[0];
@ -2814,8 +2814,8 @@ if ((stat = reset_all_p (0)) != SCPE_OK) {
sim_failed_reset_dptr->name, sim_error_text (stat));
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
sim_exit_status = EXIT_FAILURE;
goto cleanup_and_exit;
}
if (register_check) {
/* This test is explicitly run after the above reset_all_p() so that any devices
@ -2825,13 +2825,13 @@ if (register_check) {
sim_printf ("Simulator device register sanity check error\n");
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
sim_exit_status = EXIT_FAILURE;
goto cleanup_and_exit;
}
sim_printf ("*** Good Registers in %s simulator.\n", sim_name);
if (argc < 2) { /* No remaining command arguments? */
free (targv);
return EXIT_SUCCESS; /* then we're done */
sim_exit_status = EXIT_SUCCESS; /* then we're done */
goto cleanup_and_exit;
}
}
if ((stat = sim_brk_init ()) != SCPE_OK) {
@ -2839,8 +2839,8 @@ if ((stat = sim_brk_init ()) != SCPE_OK) {
sim_error_text (stat));
if (sim_ttisatty())
read_line_p ("Hit Return to exit: ", cbuf, sizeof (cbuf) - 1, stdin);
free (targv);
return EXIT_FAILURE;
sim_exit_status = EXIT_FAILURE;
goto cleanup_and_exit;
}
/* always check for register definition problems */
sim_sanity_check_register_declarations ();
@ -2901,6 +2901,8 @@ if (SCPE_BARE_STATUS(stat) == SCPE_OPENERR) /* didn't exist/can't op
if (SCPE_BARE_STATUS(stat) != SCPE_EXIT)
process_stdin_commands (SCPE_BARE_STATUS(stat), argv, FALSE);
cleanup_and_exit:
detach_all (0, TRUE); /* close files */
sim_set_deboff (0, NULL); /* close debug */
sim_set_logoff (0, NULL); /* close log */