|
From: | Carl Edquist |
Subject: | Re: [PATCH] tee: Add --pipe-check to allow instantly detecting closed outputs |
Date: | Tue, 29 Nov 2022 16:45:31 -0600 (CST) |
On Tue, 29 Nov 2022, Arsen Arsenović wrote:
The issue here isn't the compilers hanging, it's tee living longer than all the compilers do because it's stdin doesn't EOF (it'd be preferable for it to only live as long as the last of the compilers).I can imagine attempting to implement this with enough pipe and fd redirection magic, but I'm not sure how (in)elegant that becomes.
It sounds like one way or another you want to copy your endless but intermittent input to multiple output pipes, but you want to quit as soon as all the output pipes become broken.
To me, tee sounds like exactly the place to do that. Otherwise, you'd have to add the broken-pipe detection (as in your patch) to your own program, along with the rest of tee's basic functionality :)
It would be one thing if you controlled the programs that consume the input (you could have them handle 'heartbeats' in the input stream, and once these programs terminate, the heartbeats would trip on the broken pipe). (However (in)elegant that becomes to implement...)
But if you don't have control over that, the fundamental problem is detecting broken pipes *without writing to them*, and I don't think that can be solved with any amount of extra pipes and fd redirection...
Carl
[Prev in Thread] | Current Thread | [Next in Thread] |