Date: Thu, 14 May 2020 06:07:23 +0000 (UTC) From: Piotr Pawel Stefaniak <pstef@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r361027 - stable/12/bin/ps Message-ID: <202005140607.04E67NP9048399@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pstef Date: Thu May 14 06:07:23 2020 New Revision: 361027 URL: https://svnweb.freebsd.org/changeset/base/361027 Log: MFC r360786: ps: extend the non-standard option -d (tree view) to work with -p Modified: stable/12/bin/ps/ps.c Directory Properties: stable/12/ (props changed) Modified: stable/12/bin/ps/ps.c ============================================================================== --- stable/12/bin/ps/ps.c Thu May 14 06:05:24 2020 (r361026) +++ stable/12/bin/ps/ps.c Thu May 14 06:07:23 2020 (r361027) @@ -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");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005140607.04E67NP9048399>