ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/process_stats.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/process_stats.c (file contents):
Revision 1.53 by ats, Mon Apr 5 18:10:11 2004 UTC vs.
Revision 1.54 by ats, Mon Apr 5 19:55:27 2004 UTC

# Line 264 | Line 264 | sg_process_stats *sg_get_process_stats(int *entries){
264          if(kp_stats == NULL) {
265                  return NULL;
266          }
267 +        memset(kp_stats, 0, size);
268  
269          if(sysctl(mib, 3, kp_stats, &size, NULL, 0) < 0) {
270                  free(kp_stats);
# Line 276 | Line 277 | sg_process_stats *sg_get_process_stats(int *entries){
277  
278          for (i = 0; i < procs; i++) {
279                  const char *name;
280 +
281 +                if (kp_stats[i].ki_stat == 0) {
282 +                        /* FreeBSD 5 deliberately overallocates the array that
283 +                         * the sysctl returns, so we'll get a few junk
284 +                         * processes on the end that we have to ignore. (Search
285 +                         * for "overestimate by 5 procs" in
286 +                         * src/sys/kern/kern_proc.c for more details.) */
287 +                        continue;
288 +                }
289  
290                  if (VECTOR_RESIZE(proc_state, proc_state_size + 1) < 0) {
291                          return NULL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines