Make TGP_ECHO override TGP_MASK and don't try to restore the terminal

if we didn't modify it.
This commit is contained in:
Todd C. Miller
2010-06-09 10:45:07 -04:00
parent a4a6620b24
commit 3e9ecaf1ec

View File

@@ -120,10 +120,12 @@ restart:
* If we are using a tty but are not the foreground pgrp this will * If we are using a tty but are not the foreground pgrp this will
* generate SIGTTOU, so do it *before* installing the signal handlers. * generate SIGTTOU, so do it *before* installing the signal handlers.
*/ */
if (!ISSET(flags, TGP_ECHO)) {
if (ISSET(flags, TGP_MASK)) if (ISSET(flags, TGP_MASK))
neednl = term_cbreak(input); neednl = term_cbreak(input);
else if (!ISSET(flags, TGP_ECHO)) else
neednl = term_noecho(input); neednl = term_noecho(input);
}
/* /*
* Catch signals that would otherwise cause the user to end * Catch signals that would otherwise cause the user to end
@@ -155,6 +157,7 @@ restart:
(void) write(output, "\n", 1); (void) write(output, "\n", 1);
/* Restore old tty settings and signals. */ /* Restore old tty settings and signals. */
if (!ISSET(flags, TGP_ECHO))
term_restore(input, 1); term_restore(input, 1);
(void) sigaction(SIGALRM, &savealrm, NULL); (void) sigaction(SIGALRM, &savealrm, NULL);
(void) sigaction(SIGINT, &saveint, NULL); (void) sigaction(SIGINT, &saveint, NULL);