touched all sources to ease import of readline-5.1
[deliverable/binutils-gdb.git] / readline / signals.c
index f344ed834975244d880e7c5d052e5c754afed2cd..fa3e26af544e10a0eafc47a05994c6e1596ae94e 100644 (file)
@@ -1,6 +1,6 @@
 /* signals.c -- signal handling support for readline. */
 
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987, 1989, 1992 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,10 +73,6 @@ 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 *));
 
@@ -89,12 +85,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
 
 /* **************************************************************** */
 /*                                                                 */
@@ -131,11 +127,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
+  if (sig == SIGINT 
+#ifdef SIGALRM
+      || sig == SIGALRM
+#endif
+                       )
     rl_set_sighandler (sig, SIG_IGN, &dummy_cxt);
 #endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */
 
@@ -145,16 +141,16 @@ 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)
+#ifdef SIGALRM
     case SIGALRM:
 #endif
-#if defined (SIGQUIT)
+    case SIGTERM:
+#ifdef SIGQUIT
     case SIGQUIT:
 #endif
       rl_cleanup_after_signal ();
@@ -172,10 +168,13 @@ rl_signal_handler (sig)
       signal (sig, SIG_ACK);
 #endif
 
-#if defined (HAVE_KILL)
+      /* 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
       kill (getpid (), sig);
 #else
-      raise (sig);             /* assume we have raise */
+      raise (sig);
 #endif
 
       /* Let the signal that we just sent through.  */
@@ -251,7 +250,7 @@ rl_set_sighandler (sig, handler, ohandler)
   struct sigaction act;
 
   act.sa_handler = handler;
-  act.sa_flags = (sig == SIGWINCH) ? SA_RESTART : 0;
+  act.sa_flags = 0;    /* XXX - should we set SA_RESTART for SIGWINCH? */
   sigemptyset (&act.sa_mask);
   sigemptyset (&ohandler->sa_mask);
   sigaction (sig, &act, &old_handler);
@@ -293,11 +292,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)
+#ifdef SIGQUIT
       rl_maybe_set_sighandler (SIGQUIT, rl_signal_handler, &old_quit);
 #endif
 
-#if defined (SIGALRM)
+#ifdef SIGALRM
       oh = rl_set_sighandler (SIGALRM, rl_signal_handler, &old_alrm);
       if (oh == (SigHandler *)SIG_IGN)
        rl_sigaction (SIGALRM, &old_alrm, &dummy);
@@ -348,10 +347,10 @@ rl_clear_signals ()
 
       rl_sigaction (SIGINT, &old_int, &dummy);
       rl_sigaction (SIGTERM, &old_term, &dummy);
-#if defined (SIGQUIT)
+#ifdef SIGQUIT
       rl_sigaction (SIGQUIT, &old_quit, &dummy);
 #endif
-#if defined (SIGALRM)
+#ifdef SIGALRM
       rl_sigaction (SIGALRM, &old_alrm, &dummy);
 #endif
 
@@ -388,8 +387,7 @@ void
 rl_cleanup_after_signal ()
 {
   _rl_clean_up_for_exit ();
-  if (rl_deprep_term_function)
-    (*rl_deprep_term_function) ();
+  (*rl_deprep_term_function) ();
   rl_clear_signals ();
   rl_clear_pending_input ();
 }
@@ -398,8 +396,7 @@ rl_cleanup_after_signal ()
 void
 rl_reset_after_signal ()
 {
-  if (rl_prep_term_function)
-    (*rl_prep_term_function) (_rl_meta_flag);
+  (*rl_prep_term_function) (_rl_meta_flag);
   rl_set_signals ();
 }
 
@@ -420,7 +417,7 @@ rl_free_line_state ()
 
   _rl_kill_kbd_macro ();
   rl_clear_message ();
-  _rl_reset_argument ();
+  _rl_init_argument ();
 }
 
 #endif  /* HANDLE_SIGNALS */
This page took 0.031613 seconds and 4 git commands to generate.