Is there a sane way to kill a pipe's head from within the pipe's tail, at least
on tail exit? Of course, when the tail exits, the head will get SIGPIPE as soon
as it tries to output something, but can the tail explicitly kill it earlier?
On Tue, 7 Dec 2021 at 16:38, Edgar Fuß wrote:
>
> Is there a sane way to kill a pipe's head from within the pipe's tail, at
> least on tail exit? Of course, when the tail exits, the head will get SIGPIPE
> as soon
> as it tries to output something, but can the tail explicitly kill it earlier?
C
> Is there a sane way to kill a pipe's head from within the pipe's
> tail, at least on tail exit?
In general, no, I think there is not. If the pipeline was generated by
a shell, and the shell wants to do that, it certainly can arrange to,
but that's not quite what you asked. (I don't know of any
I'm confused. Is my english so bad that no-one understands what I'm asking
or is my understanding of SIGPIPE wrong?
> Can't you just close() the pipe?
Yes, of course. I wrote:
EF> Of course, when the tail exits, the head will get SIGPIPE as soon as it
EF> tries to output something, but can the
On Tue, Dec 07, 2021 at 06:38:32PM +0100, Edgar Fuß wrote:
> So the context is a collectd exec plugin translating envstat output to
> collectd
> PUTVALs. The structure is about
>
> envstat -i 10 | while read ...
> ...
> printf "PUTVAL ... || exit 1
> ...
> done
>
> After I realized what the pro
> In a similar situation I have written a script like this,
> (
> envstat -i 10 & echo $! > envstat.pid
> ) | while read ...
> ...
> ... || kill $(cat envstat.pid) && exit 1
> ...
> done
...which, besides the issues you point out, depends on having a
writable temporary fil
> I was asked about the context and what I was really trying to do.
> I didn't give the context because I thaught it was irrelevant.
> What I was really trying to do is partly trying to learn.
It is and it is is not (irrelevant, that is).
It is irrelevant to the questino you asked. But people of