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: Carl Edquist
Subject: Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs
Date: Sat, 10 Dec 2022 10:36:17 -0600 (CST)

On Fri, 9 Dec 2022, Carl Edquist wrote:

On Fri, 9 Dec 2022, Arsen Arsenović wrote:

... Also, i suspect that the pipe_check option can be disabled if the _input_ is a regular file (or block device), since (i think) these always show up as ready for reading. (This check would only need to be done once for fd 0 at program start.)

Yes, there's no point poll-driving those, since it'll be always readable, up to EOF, and never hesitate to bring more data. It might just end up being a no-op if used in current form (but I haven't tried).

Well currently if the input is a regular file, poll() immediately returns POLLIN, along with any potential errors for the output. But yes the net effective behavior is the same as if the poll() call had been skipped.

In a way i don't think it's so necessary (as it's just an optimization, and it's only relevant if the user calls tee with -P/--pipe-check despite stdin being a regular file or block device), but anyway my attached patch (0002-tee-skip-pipe-checks-if-input-is-always-ready-for-re.patch) adds logic to disable pipe_check mode in this case. (Though in order not to change the SIGPIPE semantics, -P still implies -p.)


Carl

Attachment: 0001-tee-only-fstat-outputs-if-pipe_check-is-active.patch
Description: Text Data

Attachment: 0002-tee-skip-pipe-checks-if-input-is-always-ready-for-re.patch
Description: Text Data


reply via email to

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