aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/server.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2012-01-23 16:40:26 +0000
committerPedro Alves <palves@redhat.com>2012-01-23 16:40:26 +0000
commit01b1789443badeda4f875ed61a194ca419982622 (patch)
tree58ca05048a308ba2d820b49196bfd4b7526ad362 /gdb/gdbserver/server.c
parent77a35dd897bf8b3ea4a54f6da6043165d439dfd2 (diff)
downloadgdb-01b1789443badeda4f875ed61a194ca419982622.zip
gdb-01b1789443badeda4f875ed61a194ca419982622.tar.gz
gdb-01b1789443badeda4f875ed61a194ca419982622.tar.bz2
2012-01-23 Pedro Alves <palves@redhat.com>
* server.c (main): Avoid yet another case of infinite loop while detaching/killing after a longjmp.
Diffstat (limited to 'gdb/gdbserver/server.c')
-rw-r--r--gdb/gdbserver/server.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 3080a0c..c1788a9 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -2727,13 +2727,10 @@ main (int argc, char *argv[])
inferiors, we'd end up here again, stuck in an infinite loop
trap. Be sure that if that happens, we exit immediately
instead. */
- if (setjmp (toplevel))
- {
- fprintf (stderr, "Detach or kill failed. Exiting\n");
- exit (1);
- }
-
- detach_or_kill_for_exit ();
+ if (setjmp (toplevel) == 0)
+ detach_or_kill_for_exit ();
+ else
+ fprintf (stderr, "Detach or kill failed. Exiting\n");
exit (1);
}
@@ -2779,8 +2776,20 @@ main (int argc, char *argv[])
if (exit_requested || run_once)
{
- detach_or_kill_for_exit ();
- exit (0);
+ /* If something fails and longjmps while detaching or
+ killing inferiors, we'd end up here again, stuck in an
+ infinite loop trap. Be sure that if that happens, we
+ exit immediately instead. */
+ if (setjmp (toplevel) == 0)
+ {
+ detach_or_kill_for_exit ();
+ exit (0);
+ }
+ else
+ {
+ fprintf (stderr, "Detach or kill failed. Exiting\n");
+ exit (1);
+ }
}
fprintf (stderr,