Date: Sat, 16 Apr 2022 02:18:47 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: d52eaf841577 - stable/13 - procstat(1): add ability to specify subcommands not requiring pid lists Message-ID: <202204160218.23G2IlYg025499@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d52eaf8415771cfba410daad1cabc25162e93616 commit d52eaf8415771cfba410daad1cabc25162e93616 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-04-07 18:27:12 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-04-16 02:18:18 +0000 procstat(1): add ability to specify subcommands not requiring pid lists (cherry picked from commit e79866ddf1c2147890226830838dcca5174c18e1) --- usr.bin/procstat/procstat.c | 9 ++++++++- usr.bin/procstat/procstat.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/usr.bin/procstat/procstat.c b/usr.bin/procstat/procstat.c index bb3b9e9de5a8..220f63f2703e 100644 --- a/usr.bin/procstat/procstat.c +++ b/usr.bin/procstat/procstat.c @@ -449,7 +449,8 @@ main(int argc, char *argv[]) } /* Must specify either the -a flag or a list of pids. */ - if (!(aflag == 1 && argc == 0) && !(aflag == 0 && argc > 0)) + if (!(aflag == 1 && argc == 0) && !(aflag == 0 && argc > 0) && + (cmd->cmp & PS_MODE_NO_KINFO_PROC) == 0) usage(cmd); if (memf != NULL) @@ -465,6 +466,11 @@ main(int argc, char *argv[]) xo_open_container(progname); xo_open_container(xocontainer); + if ((cmd->cmp & PS_MODE_NO_KINFO_PROC) != 0) { + cmd->cmd(prstat, NULL); + goto iter; + } + if (aflag) { p = procstat_getprocs(prstat, KERN_PROC_PROC, 0, &cnt); if (p == NULL) @@ -520,6 +526,7 @@ main(int argc, char *argv[]) } } +iter: xo_close_container(xocontainer); xo_close_container(progname); xo_finish(); diff --git a/usr.bin/procstat/procstat.h b/usr.bin/procstat/procstat.h index 5a0bc193ab45..5b54d4c4ff2f 100644 --- a/usr.bin/procstat/procstat.h +++ b/usr.bin/procstat/procstat.h @@ -44,6 +44,7 @@ enum { PS_OPT_SIGNUM = 0x08, PS_OPT_VERBOSE = 0x10, PS_MODE_COMPAT = 0x20, + PS_MODE_NO_KINFO_PROC = 0x40, }; #define PS_SUBCOMMAND_OPTS \
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202204160218.23G2IlYg025499>