commit 35b5976e69a48a3555d2b3f4436dc740998b9358
parent fe2042da8aef7ae828557724debd7c65dc5106dd
Author: Chris Allegretta <chrisa@asty.org>
Date: Sun, 21 Mar 2010 05:31:43 +0000
2010-03-21 Chris Allegretta <chrisa@asty.org>
* nano.c (page_stdin et al): Don't attempt to reset/reopen the terminal
settings when reading stdin if it was aborted with SIGINT. May fix Savannah
bug 29114 reported by Mike Frysinger.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4489 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,8 @@
+2010-03-21 Chris Allegretta <chrisa@asty.org>
+ * nano.c (page_stdin et al): Don't attempt to reset/reopen the terminal
+ settings when reading stdin if it was aborted with SIGINT. May fix Savannah
+ bug 29114 reported by Mike Frysinger.
+
2010-03-21 Mike Frysinger <vapier@gentoo.org>
* doc/syntax/c.nanorc: Add additional support for #include_next and #pragma
diff --git a/src/nano.c b/src/nano.c
@@ -1067,6 +1067,8 @@ void do_exit(void)
static struct sigaction pager_oldaction, pager_newaction; /* Original and temporary handlers for SIGINT. */
static bool pager_sig_failed = FALSE; /* Did sigaction() fail without changing the signal handlers? */
+static bool pager_input_aborted = FALSE; /* Did someone invoke the pager and abort it via ^C? */
+
/* Things which need to be run regardless of whether
we finished the stdin pipe correctly or not */
@@ -1087,7 +1089,8 @@ void finish_stdin_pager(void)
dup2(ttystdin,0);
close(ttystdin);
- tcgetattr(0, &oldterm);
+ if (!pager_input_aborted)
+ tcgetattr(0, &oldterm);
if (!pager_sig_failed && sigaction(SIGINT, &pager_oldaction, NULL) == -1)
nperror("sigaction");
terminal_init();
@@ -1099,13 +1102,15 @@ void finish_stdin_pager(void)
RETSIGTYPE cancel_stdin_pager(int signal)
{
/* Currently do nothing, just handle the intr silently */
+ pager_input_aborted = TRUE;
}
/* Let nano read stdin for the first file at least */
void stdin_pager(void)
{
endwin();
- tcsetattr(0, TCSANOW, &oldterm);
+ if (!pager_input_aborted)
+ tcsetattr(0, TCSANOW, &oldterm);
fprintf(stderr, _("Reading from stdin, ^C to abort\n"));
/* Set things up so that Ctrl-C will cancel the new process. */
@@ -1125,7 +1130,7 @@ void stdin_pager(void)
nperror("sigaction");
}
}
-
+
open_buffer("", FALSE);
finish_stdin_pager();
}