[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: Bruno Haible
Subject: Re: tee logs no output if stdout is closed
Date: Sun, 31 Aug 2008 17:39:41 +0200
User-agent: KMail/1.5.4

Hi Jim,

On 2008-07-01 you replied to a proposed new 'tee' option that makes it ignore
> Thanks for the patch, but I'm reluctant to use it
> in part because it covers only the write syscalls deriving
> from tee's explicit fwrite call.  It does not handle
> an EPIPE failure that comes of a close_stdout-induced
> write syscall, so you'd still get the offending diagnostics
> some of the time.

Right. close_stdout and more generally close_stream should be changed to
handle an EPIPE failure. An EPIPE errno value means that the kernel is telling
the program "This pipe/socket has no readers any more. You can stop writing
to it." But in close_stream we are already stopping the output to this
pipe/socket. There's no point in signalling an error about this situation.

Also, if the reader process terminated only a moment later, the fflush and
fclose would succeed, and the output would land in the kernel's pipe buffer
and be discarded at that place.

I'm therefore proposing
  - a gnulib patch to ignore EPIPE in close_stream,
  - a coreutils patch to add option '-p' to 'tee'. Revised so that when _all_
    output destinations of 'tee' have no readers any more, 'tee' terminates
    with SIGPIPE (like all reasonable filter programs that have only 1 output
    destination do).

Both patches are attached.


Attachment: coreutils-tee-diffs
Description: Text Data

Attachment: 0001--New-tee-option-p.patch
Description: Text Data

Attachment: EPIPE-in-close-stream.diff
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]