Index: event-top.c =================================================================== RCS file: /services/cvs/cvsroot/latest/gdb/gdb/event-top.c,v retrieving revision 1.1.1.8 retrieving revision 1.1.1.6.2.2 diff -u -p -r1.1.1.8 -r1.1.1.6.2.2 --- event-top.c 16 Jan 2007 01:05:29 -0000 1.1.1.8 +++ event-top.c 11 Dec 2006 18:23:23 -0000 1.1.1.6.2.2 @@ -961,6 +961,16 @@ handle_sigint (int sig) { signal (sig, handle_sigint); + /* We used to set the quit flag in async_request_quit, which is either + called when immediate_quit is 1, or when we get back to the event + loop. This is wrong, because you could be running in a loop reading + in symfiles or something, and it could be quite a while before you + get to the event loop. Instead, set quit_flag to 1 here, then mark + the sigint handler as ready. Then if somebody calls QUIT before you + get to the event loop, they will unwind as expected. */ + + quit_flag = 1; + /* If immediate_quit is set, we go ahead and process the SIGINT right away, even if we usually would defer this to the event loop. The assumption here is that it is safe to process ^C immediately if @@ -989,7 +999,14 @@ handle_sigterm (int sig) void async_request_quit (gdb_client_data arg) { - quit_flag = 1; + /* If the quit_flag has gotten reset back to 0 by the time we get + back here, that means that an exception was thrown to unwind + the current command before we got back to the event loop. So + there is no reason to call quit again here. */ + + if (quit_flag == 0) + return; + quit (); }