On Wed, 25 Oct 2006 16:28:16 -0700 Wes wrote: WH> >>>>> "RS" == Robert Story <[EMAIL PROTECTED]> writes: WH> WH> RS> No, without it a poorly written script hangs. The same could be WH> RS> said for a non-persist pass script, or even a C module. We can't WH> RS> cover all the bases. WH> WH> No, without it the *agent* hangs.
And I'm saying that any script or C module, poorly coded, can also hang the agent. When we pass control to something, we expect it to behave properly. WH> It's doing a waitpid on a pid that never exits: So there are 2 issues here. 1) A misbehaving script is not exiting when it should 2) the agent is using a blocking waitpid Both of those have reasonable fixes that don't involve hanging or killing. WH> I agree there is probably a better fix. Even (pseudo): WH> WH> close(fd); WH> while(usleep(somethingsmall) && waitpid(fd,0,WNOHANG) && count < 5) WH> count++; WH> } WH> kill WH> waitpid(fd,0,0) WH> WH> is probably better. It is better, but imho, still not good enough. Generally speaking, scripts are slow. a usleep(somethingsmall), even 5 times, is unlikely to provide a script (esp on a slow system) time to clean up. And really, is there any urgency to cleanup up the persist script? Once we close the pipes, we aren't going to be talking to it. Let the agent go on it's merry way with HUP processing and getting back to processing requests. The loop you have above could easily be converted into a callback that does the same thing, but could let to script have, essentially, as long as it wanted to clean up. A configurable option for a maximum time (say 30 seconds) would keep it from hanging around forever. Of course, then there is the corner case of a new request for the script arriving before it has exited. This is detectable by a pipe fd of -1 and a pid that is not -1. An for that (much smaller) corner case, a kill so that the script can be restarted is much more palatable. Looking at the snmpd.conf man page, I see that there is no documentation that a script should exit when stdin is closed. It should be updated. (The example script local/pass_persisttest does do the right thing.) ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders