diff options
author | Daniel Friesel <derf@finalrewind.org> | 2017-09-13 18:34:44 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2017-09-13 18:35:08 +0200 |
commit | 284207b12dbfd13c25416cba69a151f54dabb6dc (patch) | |
tree | 65dc74b0d7d456afba007a08c6d92bc4a02687f8 /src | |
parent | b7d6976e3375f7763ea615431733eccbaa33e573 (diff) |
Only restore terminal settings if stdin still belongs to us (closes #324)
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -234,7 +234,15 @@ void feh_clean_exit(void) if(disp) XCloseDisplay(disp); - if (control_via_stdin && isatty(STDIN_FILENO)) + /* + * Only restore the old terminal settings if + * - we changed them in the first place + * - stdin still is a terminal (it might have been closed) + * - stdin still belongs to us (we might have been detached from the + * controlling terminal, in that case we probably shouldn't be messing + * around with it) <https://github.com/derf/feh/issues/324> + */ + if (control_via_stdin && isatty(STDIN_FILENO) && getpgrp() == (tcgetpgrp(STDIN_FILENO))) if (tcsetattr(STDIN_FILENO, TCSANOW, &old_term_settings) == -1) eprintf("tcsetattr failed"); |