Skip to content

Commit

Permalink
restore tty attrs+flush before/after external cmd
Browse files Browse the repository at this point in the history
 * restore tty attributes from init-time termios
 * make fseek ... SEEK_END unconditional after command
 * use TCSAFLUSH when setting tty attributes to block leakage of
   keystrokes across tig/external boundary - in the "after" case,
   this is probably more robust than fseek() on the file pointer
  • Loading branch information
rolandwalker committed Aug 23, 2017
1 parent 0f436ee commit e59edc4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ open_external_viewer(const char *argv[], const char *dir, bool silent, bool conf
clear();
refresh();
endwin(); /* restore original tty modes */
tcsetattr(opt_tty.fd, TCSAFLUSH, opt_tty.attr);
ok = io_run_fg(argv, dir);
if (confirm || !ok) {
if (!ok && *notice)
fprintf(stderr, "%s", notice);
fprintf(stderr, "Press Enter to continue");
getc(opt_tty.file);
fseek(opt_tty.file, 0, SEEK_END);
}
fseek(opt_tty.file, 0, SEEK_END);
tcsetattr(opt_tty.fd, TCSAFLUSH, opt_tty.attr);
set_terminal_modes();
}

Expand Down

0 comments on commit e59edc4

Please sign in to comment.