Robert Story wrote:
On Fri, 04 Mar 2005 10:46:02 -0800 Michael wrote:
MH> Using a simple setup as described in
MH> http://www.net-snmp.org/tutorial/tutorial-5/commands/snmptrap.html, when
MH> a trap is received, the snmptrapd process fails from a broken pipe. I
MH> then use the same setup with 5.0.9 and everything functions as designed.
MH>
MH> I did a little digging and it looks like the problem is in
MH> agent/mibgroup/utilities/execute.c in run_exec_command(). I don't know
MH> a whole lot about how this is architected, but it appears that two
MH> threads are responsible for making this happen. One gets the trap
MH> handler process running and the other writes to its stdin and waits for
MH> any output.
MH>
MH> What I see happening is the thread that is initiating the trap handler
MH> does some manipulation of file descriptors, closing the standard ones
MH> and redirecting them to pipes. When it does a close(2), this function
MH> never returns. (Is this stderr?)
Yes, and it is odd that it doesn't return..
MH> In the meantime, the other thread
MH> marches ahead and attempts to write to the pipe. This is where the
MH> broken pipe happens and the process terminates.
Apparently snmpd handles this by ignoring SIGPIPE. Add this code in
snmptrapd.c, near the other signal handlers:
#ifdef SIGPIPE
signal(SIGPIPE, SIG_IGN); /* 'Inline' failure of wayward readers */
#endif
MH> I didn't see it bugged either. Should it be?
Yes, anything that causes the daemon to crash is very bad.
Thanks for the reply and suggestions. I can ignore SIGPIPE, but I'll
also have to skip the close(2) call so that the trap handler can be
started. I wonder what the effect of that might be?
Mike
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users