aboutsummaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/top.c')
-rw-r--r--gdb/top.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/gdb/top.c b/gdb/top.c
index 47d9100..0afed966 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -2763,6 +2763,17 @@ quit_command (args, from_tty)
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)
+ {
+ value_ptr val = parse_and_eval (args);
+
+ exit_code = (int) value_as_long (val);
+ }
+
if (inferior_pid != 0 && target_has_execution)
{
if (attach_flag)
@@ -2787,7 +2798,7 @@ quit_command (args, from_tty)
if (write_history_p && history_filename)
write_history (history_filename);
- exit (0);
+ exit (exit_code);
}
/* Returns whether GDB is running on a terminal and whether the user