[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tee logs no output if stdout is closed
From: |
Andreas Schwab |
Subject: |
Re: tee logs no output if stdout is closed |
Date: |
Mon, 30 Jun 2008 11:00:05 +0200 |
User-agent: |
Gnus/5.110009 (No Gnus v0.9) Emacs/22.2 (gnu/linux) |
Bruno Haible <address@hidden> writes:
> tee appears to drop its input (i.e. it does not write it into the specified
> log file) if stdout is closed.
>
> I didn't expect this behaviour, and POSIX
> http://www.opengroup.org/susv3/utilities/tee.html
> does not mandate this behaviour either. Rather, it says:
> "If any file operands are specified, the standard input shall be copied to
> each named file."
It also says:
ASYNCHRONOUS EVENTS
Default, except that if the −i option was specified, SIGINT shall
be ignored.
> $ rm -f empty; touch empty; rm -f output output2; \
> for a in 0 1 2 3 4 5 6 7 8 9 ; do \
> for b in 0 1 2 3 4 5 6 7 8 9 ; do \
> echo g$a$b | tee -a output; \
> echo h$a$b >> output2; \
> done; \
> sleep 2; \
> done \
> | { sleep 1; join --nocheck-order -v 2 - empty; }
>
> The 'join' command notices that its second argument is empty, stops reading,
> and exits immediately.
The tee process then receives a SIGPIPE when trying to write to the
broken pipe. That will kill it.
Andreas.
--
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."