commit 521e00d76102f2f42f8cfe2d44ea298e5e141290
parent 7fde37f006638c9dd7e88b9d8a5f53aa38f948b6
Author: Chris Allegretta <chrisa@asty.org>
Date: Thu, 28 Jun 2001 16:52:52 +0000
rewrote suspend handler, added sigfillset before setting up handler with sigaction, allows nano to suspend properly with mutt
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@699 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
3 files changed, 38 insertions(+), 22 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -110,6 +110,17 @@ Cvs code -
- Add Alt-whatever-[a-d] support as well as Alt-whatever-[A-D].
main()
- Code to silently process "-g" and "-j" (Rocco)
+ signal_init()
+ - Reorder sigaction calls, use sigfillset() to stop SIGTSTP and
+ SIGCONT from being interrupted, allows suspending nano
+ to work more reliably, esp. with mutt, etc.
+ do_suspend()
+ - Don't try to play with the handler inside the handler. Just
+ raise a SIGSTOP. We also now write the "use "fg"" message to
+ stdout instead of stderr.
+ do_cont()
+ - Now just does a refresh call instead of playing with the SIGTSTP
+ handler.
- nano.h:
- Updated the BROWSER_LIST_LEN for the "Goto Directory" code (Rocco)
- proto.h:
diff --git a/Makefile.in b/Makefile.in
@@ -96,7 +96,7 @@ nano_LDADD = @INTLLIBS@
info_TEXINFOS = nano.texi
MAKEINFO = makeinfo --no-split
-EXTRA_DIST = AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README TODO install-sh missing mkinstalldirs nano.1 nano.1.html faq.html nanorc.sample
+EXTRA_DIST = ABOUT-NLS AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README THANKS TODO install-sh missing mkinstalldirs nano.1 nano.1.html faq.html nanorc.sample
SUBDIRS = po intl
@@ -131,7 +131,7 @@ MANS = $(man_MANS)
NROFF = nroff
DIST_COMMON = README ./stamp-h.in ABOUT-NLS AUTHORS COPYING ChangeLog \
-INSTALL Makefile.am Makefile.in NEWS TODO acconfig.h aclocal.m4 \
+INSTALL Makefile.am Makefile.in NEWS THANKS TODO acconfig.h aclocal.m4 \
config.guess config.h.in config.sub configure configure.in install-sh \
missing mkinstalldirs texinfo.tex
diff --git a/nano.c b/nano.c
@@ -1639,25 +1639,27 @@ RETSIGTYPE handle_hup(int signal)
/* What do we do when we catch the suspend signal */
RETSIGTYPE do_suspend(int signal)
{
-
- act.sa_handler = SIG_DFL;
- sigemptyset(&act.sa_mask);
- sigaction(SIGTSTP, &act, NULL);
-
endwin();
- fprintf(stderr, "\n\n\n\n\nUse \"fg\" to return to nano\n");
- raise(SIGTSTP);
+ printf("\n\n\n\n\nUse \"fg\" to return to nano\n");
+ fflush(stdout);
+
+ /* We used to re-enable the default SIG_DFL and raise SIGTSTP, but
+ then we could be (and were) interrupted in the middle of the call.
+ So we do it the mutt way instead */
+ kill(0, SIGSTOP);
}
/* Restore the suspend handler when we come back into the prog */
RETSIGTYPE do_cont(int signal)
{
- act.sa_handler = do_suspend;
- sigemptyset(&act.sa_mask);
- sigaction(SIGTSTP, &act, NULL);
- initscr();
- total_refresh();
+ /* Now we just update the screen instead of having to reenable the
+ SIGTSTP handler */
+
+ wnoutrefresh(edit);
+ wnoutrefresh(bottomwin);
+ wnoutrefresh(topwin);
+ doupdate();
}
void handle_sigwinch(int s)
@@ -1744,9 +1746,20 @@ void signal_init(void)
act.sa_handler = SIG_IGN;
sigaction(SIGINT, &act, NULL);
+ /* Trap SIGHUP cuz we want to write the file out. */
+ act.sa_handler = handle_hup;
+ sigaction(SIGHUP, &act, NULL);
+
+ act.sa_handler = handle_sigwinch;
+ sigaction(SIGWINCH, &act, NULL);
+
if (!ISSET(SUSPEND)) {
sigaction(SIGTSTP, &act, NULL);
} else {
+ /* if we don't do this, it seems other stuff interrupts the
+ suspend handler! Try using nano with mutt without this line */
+ sigfillset(&act.sa_mask);
+
act.sa_handler = do_suspend;
sigaction(SIGTSTP, &act, NULL);
@@ -1754,14 +1767,6 @@ void signal_init(void)
sigaction(SIGCONT, &act, NULL);
}
-
- /* Trap SIGHUP cuz we want to write the file out. */
- act.sa_handler = handle_hup;
- sigaction(SIGHUP, &act, NULL);
-
- act.sa_handler = handle_sigwinch;
- sigaction(SIGWINCH, &act, NULL);
-
}
void window_init(void)