tech-userlevel archive

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

Re: sh: killing a pipe head from the tail

> It is irrelevant to the questino you asked.  But people often ask "how
> do I do XYZ?" when their problem is actually "how do I do ABC?" and
> they believe XYZ is the only way (or sometimes, the correct way) to do
> ABC.  Such people are often wrong; there are often other ways to do ABC.
Ah, OK, that's very true, as I know too well from the receiving end.

> If you want to sidestep such questions, a very brief sketch of
> why you want to do XYZ can help.  In this case, saying something like
> "I was looking at a problem which is irrelevant here, because it led me
> to wonder if there's some way for the process on the read end of a pipe
> to kill the process on the write end without depending on the writing
> process getting SIGPIPE" might help make it clear that you're looking
> for XYZ in its own right, independent of the ABC that motivated your
> initial interest in it.
Oh yes, that would have been a much better way to phrase it.

> Personally, I would call it a bug in collectd that it leaves SIGPIPE
> ignored by plugin children it forks; that is not what least surprise
> would lead me to expect.  I would say it'd be better for it to catch
> SIGPIPE and have the catcher do nothing.  That way, it'd get reset for
> free upon exec in the child.
Yes, I'm going to file a bug with collectd; I'll only need to look up 
where it may be relying on a child ignoring SIGPIPE.

> It occurs to me that you might be able to do it by having the script
> kill its entire process group.  This may or may not do what you want,
> depending on what collectd and the shell in question do with process
> groups.  It does seem to me like one of the cleaner possible solutions.
I must admit I don't know enough of the details of process groups, let alone 
the question what Poetterix has done to them (while collect_envstat surely 
only needs to work on NetBSD, derivatives may need to work on Linux).

Home | Main Index | Thread Index | Old Index