* [PATCH] SIGTERM handler
@ 2005-11-16 19:29 Andrew STUBBS
2005-11-25 18:06 ` Andrew STUBBS
2005-11-25 18:11 ` Daniel Jacobowitz
0 siblings, 2 replies; 4+ messages in thread
From: Andrew STUBBS @ 2005-11-16 19:29 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 351 bytes --]
Hi,
This patch adds a handler for SIGTERM.
The main purpose is to ensure that GDB quit through quit_force() and
therefore properly disconnects from the target. This is quite important
for our target interface and should do no harm for anybody else's.
It also ensures that --return-child-result works when GDB exits this way.
Thanks
Andrew Stubbs
[-- Attachment #2: sigterm.patch --]
[-- Type: text/plain, Size: 1704 bytes --]
2005-11-16 Andrew Stubbs <andrew.stubbs@st.com>
* event-top.h (async_init_signals): Add SIGTERM handler.
(handle_sigterm): New function.
* event-top.h (handle_sigterm): New prototype.
Index: src/gdb/event-top.c
===================================================================
--- src.orig/gdb/event-top.c 2005-11-09 12:02:37.000000000 +0000
+++ src/gdb/event-top.c 2005-11-09 12:03:22.000000000 +0000
@@ -892,6 +892,7 @@ async_init_signals (void)
signal (SIGINT, handle_sigint);
sigint_token =
create_async_signal_handler (async_request_quit, NULL);
+ signal (SIGTERM, handle_sigterm);
/* If SIGTRAP was set to SIG_IGN, then the SIG_IGN will get passed
to the inferior and breakpoints will be ignored. */
@@ -964,6 +965,15 @@ handle_sigint (int sig)
mark_async_signal_handler_wrapper (sigint_token);
}
+/* Quit GDB if SIGTERM is received.
+ GDB would quit anyway, but this way it will clean up properly. */
+void
+handle_sigterm (int sig)
+{
+ signal (sig, handle_sigterm);
+ quit_force ((char *) 0, stdin == instream);
+}
+
/* Do the quit. All the checks have been done by the caller. */
void
async_request_quit (gdb_client_data arg)
Index: src/gdb/event-top.h
===================================================================
--- src.orig/gdb/event-top.h 2003-04-12 18:41:25.000000000 +0100
+++ src/gdb/event-top.h 2005-11-09 12:02:44.000000000 +0000
@@ -97,6 +97,7 @@ extern void handle_stop_sig (int sig);
#endif
#endif
extern void handle_sigint (int sig);
+extern void handle_sigterm (int sig);
extern void pop_prompt (void);
extern void push_prompt (char *prefix, char *prompt, char *suffix);
extern void gdb_readline2 (void *client_data);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] SIGTERM handler
2005-11-16 19:29 [PATCH] SIGTERM handler Andrew STUBBS
@ 2005-11-25 18:06 ` Andrew STUBBS
2005-11-25 18:11 ` Daniel Jacobowitz
1 sibling, 0 replies; 4+ messages in thread
From: Andrew STUBBS @ 2005-11-25 18:06 UTC (permalink / raw)
To: gdb-patches
Andrew Stubbs wrote:
> This patch adds a handler for SIGTERM.
This one ought to be an easy 'yes' or 'no'.
OK?
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] SIGTERM handler
2005-11-16 19:29 [PATCH] SIGTERM handler Andrew STUBBS
2005-11-25 18:06 ` Andrew STUBBS
@ 2005-11-25 18:11 ` Daniel Jacobowitz
2005-11-25 20:13 ` Andrew STUBBS
1 sibling, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2005-11-25 18:11 UTC (permalink / raw)
To: Andrew STUBBS; +Cc: gdb-patches
On Wed, Nov 16, 2005 at 04:51:00PM +0000, Andrew STUBBS wrote:
> Hi,
>
> This patch adds a handler for SIGTERM.
>
> The main purpose is to ensure that GDB quit through quit_force() and
> therefore properly disconnects from the target. This is quite important
> for our target interface and should do no harm for anybody else's.
>
> It also ensures that --return-child-result works when GDB exits this way.
>
> Thanks
>
> Andrew Stubbs
> 2005-11-16 Andrew Stubbs <andrew.stubbs@st.com>
>
> * event-top.h (async_init_signals): Add SIGTERM handler.
> (handle_sigterm): New function.
> * event-top.h (handle_sigterm): New prototype.
I'm dubious as to the value of this, but why not - patch is OK. I
never send GDB a SIGTERM, but I send it SIGKILL on a regular basis.
I guess it may get SIGTERMs during clean shutdown.
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] SIGTERM handler
2005-11-25 18:11 ` Daniel Jacobowitz
@ 2005-11-25 20:13 ` Andrew STUBBS
0 siblings, 0 replies; 4+ messages in thread
From: Andrew STUBBS @ 2005-11-25 20:13 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz wrote:
> I'm dubious as to the value of this, but why not - patch is OK. I
> never send GDB a SIGTERM, but I send it SIGKILL on a regular basis.
> I guess it may get SIGTERMs during clean shutdown.
Thanks, committed.
FYI, this is critical here because we use the debugger with an
alternative simulator (somewhat more accurate than the ISS in GDB). If
GDB does not shut down cleanly then the simulator does not shut down
cleanly. This might be bad enough, but sometimes it will happily go on
simulating an infinite loop and consume all the host CPU. This is
particularly unhelpful when run as part of a long test and the SIGTERM
is the result of a timeout.
It also ensures --return-child-result is good, resets connections to
remote targets and probably helps out many other issues.
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-11-25 18:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-16 19:29 [PATCH] SIGTERM handler Andrew STUBBS
2005-11-25 18:06 ` Andrew STUBBS
2005-11-25 18:11 ` Daniel Jacobowitz
2005-11-25 20:13 ` Andrew STUBBS
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox