+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
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 */
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();
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. */
nperror("sigaction");
}
}
-
+
open_buffer("", FALSE);
finish_stdin_pager();
}