kvm_getprocs: gracefully handle errors from kvm_deadprocs

and don't confuse callers with incorrect return value

MFC after:	9 days
This commit is contained in:
Andriy Gapon 2012-10-06 20:16:04 +00:00
parent 9fb9ea1c03
commit ca895af355
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=241303

View file

@ -593,9 +593,15 @@ kvm_getprocs(kvm_t *kd, int op, int arg, int *cnt)
nprocs = kvm_deadprocs(kd, op, arg, nl[1].n_value,
nl[2].n_value, nprocs);
if (nprocs <= 0) {
_kvm_freeprocs(kd);
nprocs = 0;
}
#ifdef notdef
size = nprocs * sizeof(struct kinfo_proc);
(void)realloc(kd->procbase, size);
else {
size = nprocs * sizeof(struct kinfo_proc);
kd->procbase = realloc(kd->procbase, size);
}
#endif
}
*cnt = nprocs;