On Wed, Dec 24, 2025 at 09:27:18PM +0100, Alexandre Detiste wrote: > I think that even STDIN cannot be relied to be always there ... > > tchet@quieter:~$ setsid -w bts version < /dev/null > Cannot open /dev/tty: No such device or address at /usr/bin/bts line 1232.
I haven't actually released the fixed version yet. This was with my local
branch :-).
/dev/null is no problem for dup() the code is using now. The new FD will
simply cause read() to return immediately.
---
bts: Fall back to STDIN when /dev/tty fails to open (Closes: #1123934)
diff --git a/scripts/bts.pl b/scripts/bts.pl
index a7813726..7576f4b4 100755
--- a/scripts/bts.pl
+++ b/scripts/bts.pl
@@ -1390,8 +1390,13 @@ $implicit_cmd = 'reply' if $use_mua ? $inside_mua : 0;
my $stdin_isatty = isatty(\*STDIN);
if ($stdin_isatty) {
- open(TTY, "+</dev/tty") or die "Cannot open /dev/tty: $!";
+ if (not open(TTY, "+</dev/tty")) {
+ warn "$progname: WARN: Could not open /dev/tty despite STDIN being a
TTY.: $!\n";
+ warn "$progname: Falling back to using STDIN.\n";
+ goto dup_stdin;
+ }
} else {
+ dup_stdin:
open(TTY, "<&STDIN") or die "Could not dup STDIN: $!";
}
# Note: To test /dev/tty failure case use $ setsid -w sh -c './bts.pl reply'
--Daniel
signature.asc
Description: PGP signature

