Running snmp agent as a thread

jatinder goswami <[email protected]>
Newsgroups gmane.network.net-snmp.devel,gmane.network.net-snmp.user
Message-ID <CAJd+9+2vBN8VP_P_k0QQbFYKdUicm9OSaTd4WniPuhc4cccT+w@mail.gmail.com>
Hi All,

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.


Thanks,
Jatinder

------------------------------------------------------------------------------
BlackBerry&reg; 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.