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); |
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; |