turns out STDOUT may have been redirected, in which case tcgetpgrp will
authorespie <espie@openbsd.org>
Sun, 31 Jan 2021 15:22:55 +0000 (15:22 +0000)
committerespie <espie@openbsd.org>
Sun, 31 Jan 2021 15:22:55 +0000 (15:22 +0000)
return -1, in which case we never need to suppress output.

noticed by Mark Patruck

usr.sbin/pkg_add/OpenBSD/State.pm

index 8750341..1a26a9a 100644 (file)
@@ -1,5 +1,5 @@
 # ex:ts=8 sw=4:
-# $OpenBSD: State.pm,v 1.67 2021/01/30 11:19:01 espie Exp $
+# $OpenBSD: State.pm,v 1.68 2021/01/31 15:22:55 espie Exp $
 #
 # Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org>
 #
@@ -142,8 +142,11 @@ sub handle_continue
 OpenBSD::Auto::cache(can_output,
        sub {
                require POSIX;
+
                # XXX uses POSIX semantics so fd, we can hardcode stdout ;)
-               return getpgrp() == POSIX::tcgetpgrp(1); 
+               my $s = POSIX::tcgetpgrp(1);
+               # note that STDOUT may be redirected (tcgetpgrp() will fail)
+               return $s == -1 || getpgrp() == $s;
        });
 
 sub sync_display