summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPiotr Pawel Stefaniak <pstef@FreeBSD.org>2020-05-07 16:56:18 +0000
committerPiotr Pawel Stefaniak <pstef@FreeBSD.org>2020-05-07 16:56:18 +0000
commitca8c0d5e811048ad67d0955642c5b486e9c0f3d2 (patch)
tree374be17aead18daf2e3c7477a4573f60ce62d8f0 /bin
parent20077ec02c28b6f5a815348b7ec07fc51dac9f90 (diff)
downloadsrc-test2-ca8c0d5e811048ad67d0955642c5b486e9c0f3d2.tar.gz
src-test2-ca8c0d5e811048ad67d0955642c5b486e9c0f3d2.zip
Notes
Diffstat (limited to 'bin')
-rw-r--r--bin/ps/ps.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index 4a8db5d649e7..305247609510 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -506,7 +506,7 @@ main(int argc, char *argv[])
what = KERN_PROC_PGRP | showthreads;
flag = *pgrplist.l.pids;
nselectors = 0;
- } else if (pidlist.count == 1) {
+ } else if (pidlist.count == 1 && !descendancy) {
what = KERN_PROC_PID | showthreads;
flag = *pidlist.l.pids;
nselectors = 0;
@@ -544,6 +544,14 @@ main(int argc, char *argv[])
if ((kp == NULL && errno != ESRCH) || (kp != NULL && nentries < 0))
xo_errx(1, "%s", kvm_geterr(kd));
nkept = 0;
+ if (descendancy)
+ for (elem = 0; elem < pidlist.count; elem++)
+ for (i = 0; i < nentries; i++)
+ if (kp[i].ki_ppid == pidlist.l.pids[elem]) {
+ if (pidlist.count >= pidlist.maxcount)
+ expand_list(&pidlist);
+ pidlist.l.pids[pidlist.count++] = kp[i].ki_pid;
+ }
if (nentries > 0) {
if ((kinfo = malloc(nentries * sizeof(*kinfo))) == NULL)
xo_errx(1, "malloc failed");