coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed ou


From: Arsen Arsenović
Subject: Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs
Date: Fri, 02 Dec 2022 14:01:43 +0100

Carl Edquist <edquist@cs.wisc.edu> writes:

> On the topic of implementation - I was thinking more about a general solution
> for filter utils, and I am thinking the key thing is to provide a replacement
> (wrapper) for read(2), that polls two fds together (one input and one ouput),
> with no timeout.
>
> It would check for POLLIN on input (in which case do the read()). Otherwise if
> there is an error (POLLERR or POLLHUP) on input, treat it as EOF.  Otherwise 
> if
> there's an error on output, remove this output, or handle it similar to
> SIGPIPE/EPIPE.
>
> (Nothing is written to the output fd here, it's just used for polling.)

I'm concerned with adding such a behavior change by default still.  I
can imagine this "lifetime extension" properly having been relied on in
the last many decades it has been around for ;)

> Although tee has multiple outputs, you only need to monitor a single output fd
> at a time.  Because the only case you actually need to catch is when the final
> valid output becomes a broken pipe.  (So I don't think it's necessary to
> poll(2) all the output fds together.)

That is technically true, but I think coupling this to two FDs might
prove a bit inelegant in implementation (since you'd have to decide
which entry from an unorganized list with holes do you pick?  any of
them could spontaneously go away), so I'm not sure the implementation
would be cleaner that way.

Thanks, have a wonderful day.
-- 
Arsen Arsenović

Attachment: signature.asc
Description: PGP signature


reply via email to

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