diff options
| author | Daniel Friesel <derf@finalrewind.org> | 2017-08-27 12:39:03 +0200 | 
|---|---|---|
| committer | Daniel Friesel <derf@finalrewind.org> | 2017-08-27 12:39:03 +0200 | 
| commit | 9e146eb61690404a33c80645fbb46b696d48d484 (patch) | |
| tree | 6a35496dbcd0c8c334e55141a103e5eb8e0a7de4 /src | |
| parent | 6e6d355fef849998a194278f0aafe5c9e6de5139 (diff) | |
Do not accept control from stdin when running in the background
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 12 | 
1 files changed, 11 insertions, 1 deletions
| @@ -111,7 +111,17 @@ int feh_main_iteration(int block)  		fdsize = xfd + 1;  		pt = feh_get_time();  		first = 0; -		if (isatty(STDIN_FILENO) && !opt.multiwindow) { +		/* +		 * Only accept commands from stdin if +		 * - stdin is a terminal (otherwise it's probably used as an image / filelist) +		 * - we aren't running in multiwindow mode (cause it's not clear which +		 *   window commands should be applied to in that case) +		 * - we're in the same process group as stdin, AKA we're not running +		 *   in the background. Background processes are stopped with SIGTTOU +		 *   if they try to write to stdout or change terminal attributes. They +		 *   also don't get input from stdin anyway. +		 */ +		if (isatty(STDIN_FILENO) && !opt.multiwindow && getpgrp() == (tcgetpgrp(STDIN_FILENO))) {  			control_via_stdin = 1;  			struct termios ctrl;  			if (tcgetattr(STDIN_FILENO, &old_term_settings) == -1) | 
