mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-16 15:11:52 +00:00
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:
parent
a4730cdb82
commit
d7026b9671
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=324367
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user