From a7266fef19dfc55fd00c0fbe4db8b277424ea52d Mon Sep 17 00:00:00 2001 From: Andrew Stubbs Date: Fri, 25 Nov 2005 18:33:12 +0000 Subject: [PATCH] 2005-11-16 Andrew Stubbs * event-top.h (async_init_signals): Add SIGTERM handler. (handle_sigterm): New function. * event-top.h (handle_sigterm): New prototype. --- gdb/ChangeLog | 6 ++++++ gdb/event-top.c | 10 ++++++++++ gdb/event-top.h | 1 + 3 files changed, 17 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9a322f7..5b9ba2e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2005-11-25 Andrew Stubbs + * event-top.h (async_init_signals): Add SIGTERM handler. + (handle_sigterm): New function. + * event-top.h (handle_sigterm): New prototype. + +2005-11-25 Andrew Stubbs + * cli-decode.c (find_command_name_length): New function. (lookup_cmd_1): Replace loop reading command name with find_command_name_length(). diff --git a/gdb/event-top.c b/gdb/event-top.c index 438ef20..49b5666 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -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) diff --git a/gdb/event-top.h b/gdb/event-top.h index 7e48a6c..9eead41 100644 --- a/gdb/event-top.h +++ b/gdb/event-top.h @@ -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); -- 2.7.4