On 1/12/06, Francis Montagnac <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I think that the father of this bash script (lrm?) is setting the action
> of SIGPIPE to SIG_IGN, and then "cat" itself notice that and resets it
> to a function printing that on stderr.
>
> You can reproduce that reliably with the following (that doesn't call a
> shell to execute "cat"):
>
> $ perl -e '$SIG{"PIPE"} = "IGNORE"; exec "/bin/cat";' < /dev/zero | head -1c 
> > /dev/null
> /bin/cat: write error: Broken pipe
> $
>
> In addition, bash resets signals in a child process to the values they
> add upon entrance to the shell, thus adding:
>
>   trap - PIPE
>
> before calling "cat" will *not* work:
>
> $ perl -e '$SIG{"PIPE"} = "IGNORE"; exec "/bin/bash", "-c", "trap - PIPE; 
> /bin/cat";' < /dev/zero | head -1c > /dev/null
> /bin/cat: write error: Broken pipe
> $
>
> I fear you need to modify the father :-( (or of course use another
> scripting langage than bash).
>
> > Only if do like this:
>
> > cat /proc/fs/nfs/exports | grep -q "^${export_dir}[ ]"
>
> > the error goes away.
>
> When the stdin of "cat" is small it may finish writing *before* the exit
> of the reader (grep in your case). That's why I use /dev/zero in my
> tests.
>

/me is seriously impressed at this point

I just looked through the code and it looks like the LRM might be
inheriting this setting from *its* father, heartbeat, which sets the
ignore in hb_signal_set_common().

The reason appears to be related to file descriptor leaks:
./heartbeat/heartbeat.c-7238- * Revision 1.213  2002/09/26 09:20:43  horms
./heartbeat/heartbeat.c-7239- * Fixed file descriptor leak in
heartbeat side of heartbeat API.
./heartbeat/heartbeat.c:7240: * I'm not sure about ignoreing SIGPIPE,
but it will do for now.

It seems to me that we should be able to use pipes in RAs, so I would
advocate either having the LRM "un-ignore" SIGPIPE (if thats even
possible) or not have heartbeat ignore it in the first place.

Good detective work Francis :-)
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to