Index: top.c =================================================================== RCS file: /cvs/src/src/gdb/top.c,v retrieving revision 1.75 diff -u -r1.75 top.c --- top.c 16 Aug 2003 18:38:46 -0000 1.75 +++ top.c 11 Sep 2003 19:42:03 -0000 @@ -1439,28 +1439,25 @@ return 1; } -/* Quit without asking for confirmation. */ +/* Helper routine for quit_force that requires error handling. */ -void -quit_force (char *args, int from_tty) +struct qt_args { - int exit_code = 0; - - /* An optional expression may be used to cause gdb to terminate with the - value of that expression. */ - if (args) - { - struct value *val = parse_and_eval (args); + char *args; + int from_tty; +}; - exit_code = (int) value_as_long (val); - } +static int +quit_target (void *arg) +{ + struct qt_args *qt = (struct qt_args *)arg; if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution) { if (attach_flag) - target_detach (args, from_tty); + target_detach (qt->args, qt->from_tty); else - target_kill (); + target_kill (); } /* UDI wants this, to kill the TIP. */ @@ -1471,6 +1468,29 @@ write_history (history_filename); do_final_cleanups (ALL_CLEANUPS); /* Do any final cleanups before exiting */ + + return 0; +} + +/* Quit without asking for confirmation. */ + +void +quit_force (char *args, int from_tty) +{ + int exit_code = 0; + + /* An optional expression may be used to cause gdb to terminate with the + value of that expression. */ + if (args) + { + struct value *val = parse_and_eval (args); + + exit_code = (int) value_as_long (val); + } + + /* We want to handle any quit errors and exit regardless. */ + catch_errors (quit_target, args, + "Quitting: ", RETURN_MASK_ALL); exit (exit_code); }