From 87d5f1e17e32176b262a13262ac3ec16e1970596 Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?=
Date: Wed, 13 Apr 2022 17:31:47 +0100
Subject: [PATCH] tail: detect closed stdout on Solaris
* src/tail.c (check_output_alive): Use poll() on Solaris.
Also handle POLLHUP, which Solaris returns in this case.
* tests/tail-2/pipe-f.sh: Use `head -n2` rather than `sed 2q`
as Solaris sed does not exit in this case.
* NEWS: Mention the improvement.
Reported by Bruno Haible.
---
NEWS | 2 ++
src/tail.c | 8 ++++----
tests/tail-2/pipe-f.sh | 4 ++--
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/NEWS b/NEWS
index 85fd5be122..faac5c5437 100644
--- a/NEWS
+++ b/NEWS
@@ -117,6 +117,8 @@ GNU coreutils NEWS -*- outline -*-
sort --debug now diagnoses issues with --field-separator characters
that conflict with characters possibly used in numbers.
+ 'tail -f file | filter' now exits on Solaris when filter exits.
+
root invoked coreutils, that are built and run in single binary mode,
now adjust /proc/$pid/cmdline to be more specific to the utility
being run, rather than using the general "coreutils" binary name.
diff --git a/src/tail.c b/src/tail.c
index f1b7417837..a4a590a793 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -55,7 +55,7 @@
# include