mirror of
git://git.sv.gnu.org/nano.git
synced 2025-01-11 20:09:23 +03:00
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
This commit is contained in:
parent
7fde37f006
commit
521e00d761
11
ChangeLog
11
ChangeLog
@ -110,6 +110,17 @@ Cvs code -
|
|||||||
- Add Alt-whatever-[a-d] support as well as Alt-whatever-[A-D].
|
- Add Alt-whatever-[a-d] support as well as Alt-whatever-[A-D].
|
||||||
main()
|
main()
|
||||||
- Code to silently process "-g" and "-j" (Rocco)
|
- 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:
|
- nano.h:
|
||||||
- Updated the BROWSER_LIST_LEN for the "Goto Directory" code (Rocco)
|
- Updated the BROWSER_LIST_LEN for the "Goto Directory" code (Rocco)
|
||||||
- proto.h:
|
- proto.h:
|
||||||
|
@ -96,7 +96,7 @@ nano_LDADD = @INTLLIBS@
|
|||||||
info_TEXINFOS = nano.texi
|
info_TEXINFOS = nano.texi
|
||||||
MAKEINFO = makeinfo --no-split
|
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
|
SUBDIRS = po intl
|
||||||
@ -131,7 +131,7 @@ MANS = $(man_MANS)
|
|||||||
|
|
||||||
NROFF = nroff
|
NROFF = nroff
|
||||||
DIST_COMMON = README ./stamp-h.in ABOUT-NLS AUTHORS COPYING ChangeLog \
|
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 \
|
config.guess config.h.in config.sub configure configure.in install-sh \
|
||||||
missing mkinstalldirs texinfo.tex
|
missing mkinstalldirs texinfo.tex
|
||||||
|
|
||||||
|
51
nano.c
51
nano.c
@ -1639,25 +1639,27 @@ RETSIGTYPE handle_hup(int signal)
|
|||||||
/* What do we do when we catch the suspend signal */
|
/* What do we do when we catch the suspend signal */
|
||||||
RETSIGTYPE do_suspend(int signal)
|
RETSIGTYPE do_suspend(int signal)
|
||||||
{
|
{
|
||||||
|
|
||||||
act.sa_handler = SIG_DFL;
|
|
||||||
sigemptyset(&act.sa_mask);
|
|
||||||
sigaction(SIGTSTP, &act, NULL);
|
|
||||||
|
|
||||||
endwin();
|
endwin();
|
||||||
fprintf(stderr, "\n\n\n\n\nUse \"fg\" to return to nano\n");
|
printf("\n\n\n\n\nUse \"fg\" to return to nano\n");
|
||||||
raise(SIGTSTP);
|
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 */
|
/* Restore the suspend handler when we come back into the prog */
|
||||||
RETSIGTYPE do_cont(int signal)
|
RETSIGTYPE do_cont(int signal)
|
||||||
{
|
{
|
||||||
|
|
||||||
act.sa_handler = do_suspend;
|
/* Now we just update the screen instead of having to reenable the
|
||||||
sigemptyset(&act.sa_mask);
|
SIGTSTP handler */
|
||||||
sigaction(SIGTSTP, &act, NULL);
|
|
||||||
initscr();
|
wnoutrefresh(edit);
|
||||||
total_refresh();
|
wnoutrefresh(bottomwin);
|
||||||
|
wnoutrefresh(topwin);
|
||||||
|
doupdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_sigwinch(int s)
|
void handle_sigwinch(int s)
|
||||||
@ -1744,17 +1746,6 @@ void signal_init(void)
|
|||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
sigaction(SIGINT, &act, NULL);
|
sigaction(SIGINT, &act, NULL);
|
||||||
|
|
||||||
if (!ISSET(SUSPEND)) {
|
|
||||||
sigaction(SIGTSTP, &act, NULL);
|
|
||||||
} else {
|
|
||||||
act.sa_handler = do_suspend;
|
|
||||||
sigaction(SIGTSTP, &act, NULL);
|
|
||||||
|
|
||||||
act.sa_handler = do_cont;
|
|
||||||
sigaction(SIGCONT, &act, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Trap SIGHUP cuz we want to write the file out. */
|
/* Trap SIGHUP cuz we want to write the file out. */
|
||||||
act.sa_handler = handle_hup;
|
act.sa_handler = handle_hup;
|
||||||
sigaction(SIGHUP, &act, NULL);
|
sigaction(SIGHUP, &act, NULL);
|
||||||
@ -1762,6 +1753,20 @@ void signal_init(void)
|
|||||||
act.sa_handler = handle_sigwinch;
|
act.sa_handler = handle_sigwinch;
|
||||||
sigaction(SIGWINCH, &act, NULL);
|
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);
|
||||||
|
|
||||||
|
act.sa_handler = do_cont;
|
||||||
|
sigaction(SIGCONT, &act, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_init(void)
|
void window_init(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user