aboutsummaryrefslogtreecommitdiff
path: root/readline/signals.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2006-05-05 18:26:14 +0000
committerDaniel Jacobowitz <drow@false.org>2006-05-05 18:26:14 +0000
commit5bdf8622148be4764cc0757fd5b3e41f4d73b2b2 (patch)
treeec69331983824d95160ec9a14f71d6bccd23ed42 /readline/signals.c
parent7f8411279d59ee620d1e2e153329c0bd47c4ca86 (diff)
downloadgdb-5bdf8622148be4764cc0757fd5b3e41f4d73b2b2.zip
gdb-5bdf8622148be4764cc0757fd5b3e41f4d73b2b2.tar.gz
gdb-5bdf8622148be4764cc0757fd5b3e41f4d73b2b2.tar.bz2
Readline 5.1 import for HEAD.
Diffstat (limited to 'readline/signals.c')
-rw-r--r--readline/signals.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/readline/signals.c b/readline/signals.c
index fa3e26a..f344ed8 100644
--- a/readline/signals.c
+++ b/readline/signals.c
@@ -1,6 +1,6 @@
/* signals.c -- signal handling support for readline. */
-/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
@@ -73,6 +73,10 @@ typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt
# define sigemptyset(m)
#endif /* !HAVE_POSIX_SIGNALS */
+#ifndef SA_RESTART
+# define SA_RESTART 0
+#endif
+
static SigHandler *rl_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
static void rl_maybe_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
@@ -85,12 +89,12 @@ int rl_catch_signals = 1;
/* If non-zero, readline will install a signal handler for SIGWINCH. */
#ifdef SIGWINCH
int rl_catch_sigwinch = 1;
+#else
+int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */
#endif
static int signals_set_flag;
-#ifdef SIGWINCH
static int sigwinch_set_flag;
-#endif
/* **************************************************************** */
/* */
@@ -127,11 +131,11 @@ rl_signal_handler (sig)
#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
/* Since the signal will not be blocked while we are in the signal
handler, ignore it until rl_clear_signals resets the catcher. */
- if (sig == SIGINT
-#ifdef SIGALRM
- || sig == SIGALRM
-#endif
- )
+# if defined (SIGALRM)
+ if (sig == SIGINT || sig == SIGALRM)
+# else
+ if (sig == SIGINT)
+# endif
rl_set_sighandler (sig, SIG_IGN, &dummy_cxt);
#endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */
@@ -141,16 +145,16 @@ rl_signal_handler (sig)
rl_free_line_state ();
/* FALLTHROUGH */
+ case SIGTERM:
#if defined (SIGTSTP)
case SIGTSTP:
case SIGTTOU:
case SIGTTIN:
#endif /* SIGTSTP */
-#ifdef SIGALRM
+#if defined (SIGALRM)
case SIGALRM:
#endif
- case SIGTERM:
-#ifdef SIGQUIT
+#if defined (SIGQUIT)
case SIGQUIT:
#endif
rl_cleanup_after_signal ();
@@ -168,13 +172,10 @@ rl_signal_handler (sig)
signal (sig, SIG_ACK);
#endif
- /* If we have the POSIX kill function, use it; otherwise, fall
- back to the ISO C raise function. (Windows is an example of
- a platform that has raise, but not kill.) */
-#ifdef HAVE_KILL
+#if defined (HAVE_KILL)
kill (getpid (), sig);
#else
- raise (sig);
+ raise (sig); /* assume we have raise */
#endif
/* Let the signal that we just sent through. */
@@ -250,7 +251,7 @@ rl_set_sighandler (sig, handler, ohandler)
struct sigaction act;
act.sa_handler = handler;
- act.sa_flags = 0; /* XXX - should we set SA_RESTART for SIGWINCH? */
+ act.sa_flags = (sig == SIGWINCH) ? SA_RESTART : 0;
sigemptyset (&act.sa_mask);
sigemptyset (&ohandler->sa_mask);
sigaction (sig, &act, &old_handler);
@@ -292,11 +293,11 @@ rl_set_signals ()
{
rl_maybe_set_sighandler (SIGINT, rl_signal_handler, &old_int);
rl_maybe_set_sighandler (SIGTERM, rl_signal_handler, &old_term);
-#ifdef SIGQUIT
+#if defined (SIGQUIT)
rl_maybe_set_sighandler (SIGQUIT, rl_signal_handler, &old_quit);
#endif
-#ifdef SIGALRM
+#if defined (SIGALRM)
oh = rl_set_sighandler (SIGALRM, rl_signal_handler, &old_alrm);
if (oh == (SigHandler *)SIG_IGN)
rl_sigaction (SIGALRM, &old_alrm, &dummy);
@@ -347,10 +348,10 @@ rl_clear_signals ()
rl_sigaction (SIGINT, &old_int, &dummy);
rl_sigaction (SIGTERM, &old_term, &dummy);
-#ifdef SIGQUIT
+#if defined (SIGQUIT)
rl_sigaction (SIGQUIT, &old_quit, &dummy);
#endif
-#ifdef SIGALRM
+#if defined (SIGALRM)
rl_sigaction (SIGALRM, &old_alrm, &dummy);
#endif
@@ -387,7 +388,8 @@ void
rl_cleanup_after_signal ()
{
_rl_clean_up_for_exit ();
- (*rl_deprep_term_function) ();
+ if (rl_deprep_term_function)
+ (*rl_deprep_term_function) ();
rl_clear_signals ();
rl_clear_pending_input ();
}
@@ -396,7 +398,8 @@ rl_cleanup_after_signal ()
void
rl_reset_after_signal ()
{
- (*rl_prep_term_function) (_rl_meta_flag);
+ if (rl_prep_term_function)
+ (*rl_prep_term_function) (_rl_meta_flag);
rl_set_signals ();
}
@@ -417,7 +420,7 @@ rl_free_line_state ()
_rl_kill_kbd_macro ();
rl_clear_message ();
- _rl_init_argument ();
+ _rl_reset_argument ();
}
#endif /* HANDLE_SIGNALS */