pv/display: handle error of tcgetpgrp() in pv_in_foreground()
Show pv progress bar even if no terminal is set, e.g., in a busybox init script. The description of pv_in_forground() states it will return true "if we aren't outputting to a terminal". However, this is not the case since tcgetpgrg() will return an error and set ERRNO to ENOTTY if the output fd is not an tty. We now handle this error correctly and pv_in_foreground() returns also true in that case. Signed-off-by: Michael Weiß <michael.weiss@aisec.fraunhofer.de>
This commit is contained in:
@@ -48,6 +48,10 @@ bool pv_in_foreground(void)
|
||||
|
||||
our_process_group = getpgrp();
|
||||
tty_process_group = tcgetpgrp(STDERR_FILENO);
|
||||
|
||||
if (tty_process_group == -1 && errno == ENOTTY)
|
||||
return true;
|
||||
|
||||
if (our_process_group == tty_process_group)
|
||||
return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user