>>>>> On Mon, 30 Aug 2010 16:52:48 -0700, Wes Hardaker 
>>>>> <[email protected]> said:

WH> The following patch ensures that the status file still exists.  I
WH> watched a process disappear in the middle of debugging and actually saw
WH> this error live (when looking for something totally unrelated).

Scratch that, this is safer:

diff --git a/net-snmp/agent/mibgroup/host/data_access/swrun_procfs_status.c 
b/net-snmp/agent/mibgroup/host/data_access/swrun_procfs_status.c
index 0c562f6..77d4394 100644
--- a/net-snmp/agent/mibgroup/host/data_access/swrun_procfs_status.c
+++ b/net-snmp/agent/mibgroup/host/data_access/swrun_procfs_status.c
@@ -71,7 +71,6 @@ netsnmp_arch_swrun_container_load( netsnmp_container 
*container, u_int flags)
         entry = netsnmp_swrun_entry_create(pid);
         if (NULL == entry)
             continue;   /* error already logged by function */
-        rc = CONTAINER_INSERT(container, entry);
 
         /*
          * Now extract the interesting information
@@ -83,10 +82,14 @@ netsnmp_arch_swrun_container_load( netsnmp_container 
*container, u_int flags)
          */
         snprintf( buf2, BUFSIZ, "/proc/%d/status", pid );
         fp = fopen( buf2, "r" );
+        if (!fp)
+            continue; /* file (process) probably went away */
         memset(buf, 0, sizeof(buf));
         fgets( buf, BUFSIZ-1, fp );
         fclose(fp);
 
+        rc = CONTAINER_INSERT(container, entry);
+
         for ( cp = buf; *cp != ':'; cp++ )
             ;
         while (isspace(*(++cp)))       /* Skip ':' and following spaces */


-- 
Wes Hardaker
Please mail all replies to [email protected]

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to