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: Tue, 13 Dec 2022 20:36:52 +0100

Hi Carl, Padraig,

Thanks for the ACK.  I've sent the signed copyright assignment form;
I'll keep you posted on that.

On Tue, 13 Dec 2022, Pádraig Brady wrote:

>> Re HAVE_INOTIFY, that's really a proxy for a linux kernel, and so would be
>> most appropriately changed to:
>>
>>  defined __linux__ || defined __ANDROID__
>>
>> I'm thinking these hardcoded defines would be best for now at least as it
>> covers the vast majority of systems, and avoids complicated (cross) compile
>> time checks.

It might also be good to give a quick test on FreeBSD, since it has some
popularity too.

>> A modularised iopoll.c would be better, given the potential uses by other
>> tools, though we'd probably release for just tee initially.
>>
>> As for interface to this functionality I'm wondering if we could just have
>> the existing tee {-p,--output-error} imply the use of poll() on output.
>>
>> I.e. from a high level -p just means to deal more appropriately with non file
>> outputs, and as part of that, dealing immediately with closed outputs would
>> be an improvement.

That seems reasonable to me.

>> Note also tail(1) enables this functionality by default. I'm not sure about
>> other utilities, but we can deal with that later if needed.

Carl Edquist via GNU coreutils General Discussion <coreutils@gnu.org> writes:

>
> Thanks Pádraig for the feedback - that all sounds good.
>
> Will try to follow-up sometime this week...

If you prefer, I'll have some time in the latter part of this week too.

Let's not forget to include the testcase posted previously (with -p
instead of -P, since it was suggested to enable polling for -p):

( sleep 5 | (timeout 3 tee -p 2>/dev/null && echo TEST_PASSED >&8) | : ) 8>&1 | 
grep -qx TEST_PASSED

To annotate it, and let's include this info in a comment:

- sleep emulates misbehaving input.
- The timeout is our failure safety-net.
- We ignore stderr from tee, and should have no stdout anyway.
- If that succeeds, we print TEST_PASSED into FD 8 to grep for later.
  (FD 8 was selected by a D20 roll, or rather, a software emulation)
- The colon is the immediately closed output process.
- We redirect 8 back into stdout to grep it.

If tee fails, for instance because it times out, or it fails to
recognize -P for some reason, the echo simply won't run.  The grep
options are in POSIX (or, at least, in POSIX.1-2017).

Thank you both, have a great night.
-- 
Arsen Arsenović

Attachment: signature.asc
Description: PGP signature


reply via email to

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