Minor simplification of term_donate/term_steal

No functional change.
This commit is contained in:
Johannes Altmanninger 2022-07-24 14:18:22 +02:00
parent e04785604a
commit 368b68ff47

View File

@ -944,8 +944,7 @@ static void redirect_tty_after_sighup() {
/// Give up control of terminal. /// Give up control of terminal.
static void term_donate(bool quiet = false) { static void term_donate(bool quiet = false) {
while (true) { while (tcsetattr(STDIN_FILENO, TCSANOW, &tty_modes_for_external_cmds) == -1) {
if (tcsetattr(STDIN_FILENO, TCSANOW, &tty_modes_for_external_cmds) == -1) {
if (errno == EIO) redirect_tty_output(); if (errno == EIO) redirect_tty_output();
if (errno != EINTR) { if (errno != EINTR) {
if (!quiet) { if (!quiet) {
@ -954,8 +953,6 @@ static void term_donate(bool quiet = false) {
} }
break; break;
} }
} else
break;
} }
} }
@ -982,16 +979,13 @@ void term_copy_modes() {
/// Grab control of terminal. /// Grab control of terminal.
static void term_steal() { static void term_steal() {
term_copy_modes(); term_copy_modes();
while (true) { while (tcsetattr(STDIN_FILENO, TCSANOW, &shell_modes) == -1) {
if (tcsetattr(STDIN_FILENO, TCSANOW, &shell_modes) == -1) {
if (errno == EIO) redirect_tty_output(); if (errno == EIO) redirect_tty_output();
if (errno != EINTR) { if (errno != EINTR) {
FLOGF(warning, _(L"Could not set terminal mode for shell")); FLOGF(warning, _(L"Could not set terminal mode for shell"));
perror("tcsetattr"); perror("tcsetattr");
break; break;
} }
} else
break;
} }
termsize_container_t::shared().invalidate_tty(); termsize_container_t::shared().invalidate_tty();