GNU bug report logs - #22195
deviation from POSIX in tee

Previous Next

Package: coreutils;

Reported by: Eric Renouf <erenouf <at> skaion.com>

Date: Thu, 17 Dec 2015 20:35:01 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eric Renouf <erenouf <at> skaion.com>
To: 22195 <at> debbugs.gnu.org
Subject: bug#22195: deviation from POSIX in tee
Date: Thu, 17 Dec 2015 15:17:29 -0500 (Eastern Standard Time)
When using tee with process substitution, if the process exits early it 
will cause tee to get a SIGPIPE after trying to write to the closed named 
pipe (per man 2 write).  This causes tee to exit without finishing writing 
to any additional files or processes, which seems to be a violation of the 
POSIX standard at 
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/tee.html

specifically the Consequences of Errors section which states

"If a write to any successfully opened file operand fails, writes to other 
successfully opened file operands and standard output shall continue, but 
the exit status shall be non-zero. Otherwise, the default actions 
specified in Utility Description Defaults apply."

To recreate the problem I ran the following under bash:

for i in {1..300}; do
    echo "$i"
    echo "$i" >&2
    sleep 1
done | tee >(head -1 > h.txt; echo "Head done") \
 >(tail -1 > t.txt) >/dev/null

And I see output like the following:

1
Head done
2

and then it exits with echo "${PIPESTATUS[@]}" showing

141 141

and t.txt from the second process substitution only having "1" in it

This was found from a Stack Overflow question at
http://stackoverflow.com/questions/34340706/incorrect-results-with-bash-process-substitution-and-tail

I have verified this behavior with tee (GNU coreutils) 8.5 and tee (GNU 
coreutils) 8.13




This bug report was last modified 6 years and 263 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.