From nobody Sat Apr 09 21:48:25 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 37B271A8B294; Sat, 9 Apr 2022 21:48:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KbTJT6ZW9z4dZd; Sat, 9 Apr 2022 21:48:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649540906; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=a2j1Db/JVD2LPxFFD+Z3PJzHLtOArL+qwRVefYV8i8U=; b=OBDBUfHFp7VePyC8VI9f0lGxQpPhuHh3c5FID6r5DWwdM8HhrtoufA/uwiHt04LT0i1sUA xYBEB8otFxRLZ5xHNCJ68xen4Y/ImDm4iyNlfIuKxa/xU5yiaEFxdwr8YNtzOJvtp85liZ 2pKXSpf63YmnfQFoYMwZQyEOIt4EZzI6q21+F7/6EJ3SONXv35zxPQRGptf/5dLQzYC3as F9gZBLRxSWNzb9Uu+3ul/UULUywvYgt/SRJbeV8khi+g4yY62jDINhUCDIDPAgbGnWZ3eB A1mLenpb/GtdVDDXRRBT+Hlwk7pGI6QwThDMiwQcGdW2C1yNJ1jJwwofi4bBbw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 50BE821A1D; Sat, 9 Apr 2022 21:48:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 239LmPU8093167; Sat, 9 Apr 2022 21:48:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 239LmPRA093164; Sat, 9 Apr 2022 21:48:25 GMT (envelope-from git) Date: Sat, 9 Apr 2022 21:48:25 GMT Message-Id: <202204092148.239LmPRA093164@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: e79866ddf1c2 - main - procstat(1): add ability to specify subcommands not requiring pid lists List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e79866ddf1c2147890226830838dcca5174c18e1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649540906; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=a2j1Db/JVD2LPxFFD+Z3PJzHLtOArL+qwRVefYV8i8U=; b=bpefiYQ3Ci9f2d6Lro/nXK7Gijxoz0R7SpSENHRUT9zOc2DEniYCGRhq7H7eW1AoOtBv5Y 8xryq98tNC9Ky8uVeA/dNqpC7UyxITKg2gSgLaW3xG7HdxYiK/4Rg4X17Gx6JLr7gpDR5o V3pPQFD2p8pICp1ooXiKQTauN3nQQljP+4dM+ZaQpxEBWIE74vFj5YyifytkET4+i9hdhg depvjzCZs071nx2TfQ/e3AWvfD97Vx8q2lNYShG4rzB+tiKzat3pX9Ex/d91JD+H8D91/+ mHTXNEPv3r2sfxPoqktlT8X47yL6ddDb4NGhc3F7XYuKPQicFkYyg5qMNy+x7g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649540906; a=rsa-sha256; cv=none; b=f93WRo7g4n1FmJVoGuQSs8ye9ga1mD8JiB/0wigU/GbO4ZrkiYT/k+oEOhLnsZJSNK1Lzj EfPtADi9Y39YWdQj+Yew3u/9B3trvHafJv7mkaa1QbyqBlceRgFBlFmIy2MGDknlGNsUVL toVPOqoTVE3X90Nc2ZmlSatEE6WRgVWgyK2xR1Yd8PhtTYf9qcAOXwimyYleNaDoo4PXI0 381HRT3QL9KARdUMZ04KrerhinYzCpmPJhRspcm53Z9Q6QWhxut5wiaT3445fedE9tKWqZ YzsiWBlTezjQ+C6Dl393covrRI5PK6plRps/cgYI05eJ0z5YXs6/Rr65GfXPGw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e79866ddf1c2147890226830838dcca5174c18e1 commit e79866ddf1c2147890226830838dcca5174c18e1 Author: Konstantin Belousov AuthorDate: 2022-04-07 18:27:12 +0000 Commit: Konstantin Belousov CommitDate: 2022-04-09 21:47:50 +0000 procstat(1): add ability to specify subcommands not requiring pid lists Add PS_MODE_NO_KINFO_PROC cmd modifier that indicates that neither process list should be queried from the kernel, nor list of pids or `-a` switch provided on the command line to filter the output. This is intended for use by commands that query information not neccessary attributed to specific process. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D34834 --- 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 \