Re: Running snmp agent as a thread
Bart Van Assche <[email protected]>
| Newsgroups | gmane.network.net-snmp.devel,gmane.network.net-snmp.user |
|---|---|
| Message-ID | <CAO+b5-qbru=khY-OtVs6iO_8RnatfLguc++grY_ZAupZNTdReQ@mail.gmail.com> |
On Fri, Aug 5, 2011 at 9:14 AM, jatinder goswami <[email protected] > wrote: > I have a requirement to run SNMP Agent as a thread in my application (The > application in running on Linux based embedded system). > > Following are the changes I have done for same: > 1. Modified main() function in agent/snmpd.c to snmpd_main(). > 2. Compile snmpd.c as a shared library which is linked in my main > application. > 3. Start snmpd_main() function as a thread from my application. The > argument passed are "-C --rwcommunity=test". > > As soon as I start my application, it works for some time, but becomes > unusable after that(hangs). I see some code in snmpd.c which closes all file > descriptors. > > ===== > /* > * close all non-standard file descriptors we may have > * inherited from the shell. > */ > for (i = getdtablesize() - 1; i > 2; --i) { > (void) close(i); > } > > ===== > > I am not sure why this code is closing all the file descriptors. If this > code is removed, my application gives page fault. > > Have anybody run snmp agent as a thread in Linux. > Please use the AgentX protocol instead of running the SNMP agent as a thread. It will save you *a lot* of time and trouble. An example can be found here: http://www.net-snmp.org/tutorial/tutorial-5/toolkit/demon/index.html. Bart. ------------------------------------------------------------------------------ BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA The must-attend event for mobile developers. Connect with experts. Get tools for creating Super Apps. See the latest technologies. Sessions, hands-on labs, demos & much more. Register early & save! http://p.sf.net/sfu/rim-blackberry-1 _______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders