summaryrefslogtreecommitdiff
path: root/signals.c
diff options
context:
space:
mode:
Diffstat (limited to 'signals.c')
-rw-r--r--signals.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/signals.c b/signals.c
index 8e9c0ae..f344ed8 100644
--- a/signals.c
+++ b/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.
@@ -131,7 +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 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,14 +145,18 @@ rl_signal_handler (sig)
rl_free_line_state ();
/* FALLTHROUGH */
+ case SIGTERM:
#if defined (SIGTSTP)
case SIGTSTP:
case SIGTTOU:
case SIGTTIN:
#endif /* SIGTSTP */
+#if defined (SIGALRM)
case SIGALRM:
- case SIGTERM:
+#endif
+#if defined (SIGQUIT)
case SIGQUIT:
+#endif
rl_cleanup_after_signal ();
#if defined (HAVE_POSIX_SIGNALS)
@@ -164,7 +172,11 @@ rl_signal_handler (sig)
signal (sig, SIG_ACK);
#endif
+#if defined (HAVE_KILL)
kill (getpid (), sig);
+#else
+ raise (sig); /* assume we have raise */
+#endif
/* Let the signal that we just sent through. */
#if defined (HAVE_POSIX_SIGNALS)
@@ -281,8 +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);
+#if defined (SIGQUIT)
rl_maybe_set_sighandler (SIGQUIT, rl_signal_handler, &old_quit);
+#endif
+#if defined (SIGALRM)
oh = rl_set_sighandler (SIGALRM, rl_signal_handler, &old_alrm);
if (oh == (SigHandler *)SIG_IGN)
rl_sigaction (SIGALRM, &old_alrm, &dummy);
@@ -294,6 +309,7 @@ rl_set_signals ()
if (oh != (SigHandler *)SIG_DFL && (old_alrm.sa_flags & SA_RESTART))
rl_sigaction (SIGALRM, &old_alrm, &dummy);
#endif /* HAVE_POSIX_SIGNALS */
+#endif /* SIGALRM */
#if defined (SIGTSTP)
rl_maybe_set_sighandler (SIGTSTP, rl_signal_handler, &old_tstp);
@@ -332,8 +348,12 @@ rl_clear_signals ()
rl_sigaction (SIGINT, &old_int, &dummy);
rl_sigaction (SIGTERM, &old_term, &dummy);
+#if defined (SIGQUIT)
rl_sigaction (SIGQUIT, &old_quit, &dummy);
+#endif
+#if defined (SIGALRM)
rl_sigaction (SIGALRM, &old_alrm, &dummy);
+#endif
#if defined (SIGTSTP)
rl_sigaction (SIGTSTP, &old_tstp, &dummy);
@@ -368,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 ();
}
@@ -377,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 ();
}
@@ -398,7 +420,7 @@ rl_free_line_state ()
_rl_kill_kbd_macro ();
rl_clear_message ();
- _rl_init_argument ();
+ _rl_reset_argument ();
}
#endif /* HANDLE_SIGNALS */