Fix kvm_getprocs(3) error reporting in ps(1).
Previously it just didn't work at all - kvm_getprocs(3) doesn't update the &nentries when it returns NULL. The end result was that ps(1) showed garbage data instead of reporting kinfo_proc size mismatch. Reviewed by: cem Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D12414
This commit is contained in:
+5
-1
@@ -523,7 +523,11 @@ main(int argc, char *argv[])
|
||||
*/
|
||||
nentries = -1;
|
||||
kp = kvm_getprocs(kd, what, flag, &nentries);
|
||||
if ((kp == NULL && nentries > 0) || (kp != NULL && nentries < 0))
|
||||
/*
|
||||
* Ignore ESRCH to preserve behaviour of "ps -p nonexistent-pid"
|
||||
* not reporting an error.
|
||||
*/
|
||||
if ((kp == NULL && errno != ESRCH) || (kp != NULL && nentries < 0))
|
||||
xo_errx(1, "%s", kvm_geterr(kd));
|
||||
nkept = 0;
|
||||
if (nentries > 0) {
|
||||
|
||||
Reference in New Issue
Block a user