Update to latest madtty.
[apps/madmutt.git] / lib-sys / mutt_signal.c
index 115460d..2728656 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <lib-lib/lib-lib.h>
 
-#include <lib-ui/curses.h>
+#include <lib-ui/lib-ui.h>
 
 #include "mutt_signal.h"
 
@@ -22,15 +22,10 @@ static int IsEndwin = 0;
 /* Attempt to catch "ordinary" signals and shut down gracefully. */
 static void exit_handler (int sig)
 {
-  curs_set (1);
-  endwin ();                    /* just to be safe */
-  printf(_("Caught %s...  Exiting.\n"), strsignal(sig));
-  exit (0);
-}
-
-static void chld_handler(int sig __attribute__((unused)))
-{
-  /* empty */
+    curs_set(1);
+    endwin();                    /* just to be safe */
+    printf(_("Caught %s...  Exiting.\n"), strsignal(sig));
+    exit(0);
 }
 
 static void sighandler (int sig)
@@ -39,8 +34,6 @@ static void sighandler (int sig)
 
   switch (sig) {
   case SIGTSTP:                /* user requested a suspend */
-    if (!option (OPTSUSPEND))
-      break;
     IsEndwin = isendwin ();
     curs_set (1);
     if (!IsEndwin)
@@ -49,36 +42,25 @@ static void sighandler (int sig)
 
   case SIGCONT:
     if (!IsEndwin)
-      refresh ();
+      refresh();
     mutt_curs_set (-1);
-#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
     /* We don't receive SIGWINCH when suspended; however, no harm is done by
      * just assuming we received one, and triggering the 'resize' anyway. */
+  case SIGWINCH:
     SigWinch = 1;
-#endif
     break;
 
-#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
-  case SIGWINCH:
-    SigWinch = 1;
+  case SIGCHLD:
+    SigChild = 1;
     break;
-#endif
 
   case SIGINT:
     SigInt = 1;
     break;
-
   }
   errno = save_errno;
 }
 
-#ifdef USE_SLANG_CURSES
-int mutt_intr_hook (void)
-{
-  return (-1);
-}
-#endif /* USE_SLANG_CURSES */
-
 void mutt_signal_initialize (void)
 {
   struct sigaction act;
@@ -112,30 +94,16 @@ void mutt_signal_initialize (void)
   sigaction (SIGCONT, &act, NULL);
   sigaction (SIGTSTP, &act, NULL);
   sigaction (SIGINT, &act, NULL);
-#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
   sigaction (SIGWINCH, &act, NULL);
-#endif
 
   /* POSIX doesn't allow us to ignore SIGCHLD,
    * so we just install a dummy handler for it
    */
-  act.sa_handler = chld_handler;
   /* don't need to block any other signals here */
   sigemptyset (&act.sa_mask);
   /* we don't want to mess with stopped children */
   act.sa_flags |= SA_NOCLDSTOP;
   sigaction (SIGCHLD, &act, NULL);
-
-#ifdef USE_SLANG_CURSES
-  /* This bit of code is required because of the implementation of
-   * SLcurses_wgetch().  If a signal is received (like SIGWINCH) when we
-   * are in blocking mode, SLsys_getkey() will not return an error unless
-   * a handler function is defined and it returns -1.  This is needed so
-   * that if the user resizes the screen while at a prompt, it will just
-   * abort and go back to the main-menu.
-   */
-  SLang_getkey_intr_hook = mutt_intr_hook;
-#endif
 }
 
 /* signals which are important to block while doing critical ops */
@@ -147,9 +115,7 @@ void mutt_block_signals (void)
     sigaddset (&Sigset, SIGHUP);
     sigaddset (&Sigset, SIGTSTP);
     sigaddset (&Sigset, SIGINT);
-#if defined (USE_SLANG_CURSES) || defined (HAVE_RESIZETERM)
     sigaddset (&Sigset, SIGWINCH);
-#endif
     sigprocmask (SIG_BLOCK, &Sigset, 0);
     set_option (OPTSIGNALSBLOCKED);
   }