* src/date.c: Include stdio--.h.
* tests/date/date-tz.sh: Add a test case that
times out without the fix.
---
 src/date.c            |  2 +-
 tests/date/date-tz.sh | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/date.c b/src/date.c
index ebd23fe16..50689c704 100644
--- a/src/date.c
+++ b/src/date.c
@@ -17,7 +17,6 @@
    David MacKenzie <[email protected]> */
 
 #include <config.h>
-#include <stdio.h>
 #include <getopt.h>
 #include <sys/types.h>
 #if HAVE_LANGINFO_CODESET
@@ -31,6 +30,7 @@
 #include "quote.h"
 #include "show-date.h"
 #include "stat-time.h"
+#include "stdio--.h"
 #include "xsetenv.h"
 
 /* The official name of this program (e.g., no 'g' prefix).  */
diff --git a/tests/date/date-tz.sh b/tests/date/date-tz.sh
index 6530bbbf5..80a776e93 100755
--- a/tests/date/date-tz.sh
+++ b/tests/date/date-tz.sh
@@ -50,4 +50,17 @@ if test "$(TZ=America/Belize date +%z)" = '-0600'; then
 
 fi
 
+# A TZ lookup through /dev/stdin must not reopen the -f FIFO on fd 0.
+# glibc at least supports the rule in TZ="rule" being an absolute
+# path to a compiled timezone file.
+date_line='TZ="/dev/stdin" 1970-01-01'
+if timeout 10 date -d "$date_line" +%s <&- >exp 2>/dev/null &&
+   mkfifo dates; then
+  cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
+  # Omit the newline so date sees EOF before it looks up the time zone.
+  printf %s "$date_line" >dates & pid=$!
+  timeout 10 date -f dates +%s <&- >out || fail=1
+  compare exp out || fail=1
+fi
+
 Exit $fail
-- 
2.56.0


Reply via email to