bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tee logs no output if stdout is closed


From: Jim Meyering
Subject: Re: tee logs no output if stdout is closed
Date: Fri, 03 Oct 2008 11:40:31 +0200

Bruno Haible <address@hidden> wrote:
> Jim Meyering wrote:
>> >    * lib/close-stream.c (close_stream): Ignore error EPIPE from fclose.
>> >
>> I know this condition arises only when ignoring or handling SIGPIPE,
>> (which should be rather unusual) but even so, I really dislike the idea
>> of ignoring a write error.  Even if the write error would not occur
>> with slightly less output data, it's still one less _legitimate_ error
>> that can be reported.  If there is an EPIPE error, IMHO, close_stream
>> must diagnose it.
>
> This does not convince me, because EPIPE is part of the normal shutdown
> protocol of pipes, when the pipe writer chooses to block or ignore SIGPIPE.

First, you're assuming that the pipe writer chooses to
block or ignore SIGPIPE, which is not generally recommended.
But that's ok.  Just be aware that the discussion below
is relevant only in relatively unusual circumstances.

The problem is that close_stream is intended to be a general-purpose
function, and I think it must always report a write failure, even if in
some applications like yours, those are always deemed ignorable.

Imagine a scenario in which the pipe reader is expected always to
be reading, and so the pipe writer can expect that any write failure with
errno==EPIPE indicates the reader has terminated unexpectedly.  With your
modification, a pipe writer using close_stream would be unable to detect
a write failure due to EPIPE.




reply via email to

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