Author: pstef Date: Thu May 28 13:19:41 2020 New Revision: 361585 URL: https://svnweb.freebsd.org/changeset/base/361585
Log: MFS r361026 ps: extend the non-standard option -d (tree view) to work with -p Approved by: re (gjb) Modified: releng/11.4/bin/ps/ps.c Directory Properties: releng/11.4/ (props changed) Modified: releng/11.4/bin/ps/ps.c ============================================================================== --- releng/11.4/bin/ps/ps.c Thu May 28 09:52:28 2020 (r361584) +++ releng/11.4/bin/ps/ps.c Thu May 28 13:19:41 2020 (r361585) @@ -490,7 +490,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; @@ -528,6 +528,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"); _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"