From owner-svn-src-head@freebsd.org Mon Oct 5 13:52:31 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AE341425511; Mon, 5 Oct 2020 13:52:31 +0000 (UTC) (envelope-from fernape@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C4hqg4D3Vz3gKd; Mon, 5 Oct 2020 13:52:31 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7444D16852; Mon, 5 Oct 2020 13:52:31 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 095DqV9I032712; Mon, 5 Oct 2020 13:52:31 GMT (envelope-from fernape@FreeBSD.org) Received: (from fernape@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 095DqVlf032711; Mon, 5 Oct 2020 13:52:31 GMT (envelope-from fernape@FreeBSD.org) Message-Id: <202010051352.095DqVlf032711@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fernape set sender to fernape@FreeBSD.org using -f From: =?UTF-8?Q?Fernando_Apestegu=c3=ada?= Date: Mon, 5 Oct 2020 13:52:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366448 - head/bin/pkill X-SVN-Group: head X-SVN-Commit-Author: fernape X-SVN-Commit-Paths: head/bin/pkill X-SVN-Commit-Revision: 366448 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Oct 2020 13:52:31 -0000 Author: fernape (ports committer) Date: Mon Oct 5 13:52:31 2020 New Revision: 366448 URL: https://svnweb.freebsd.org/changeset/base/366448 Log: pkill(1): Add EXAMPLES section to man page Add a dozen of examples to the EXAMPLES section for pgrep(1) and pkill(1). Flags covered: -f, -F, -n, -j, -l, -S, -x Approved by: mandoc (bcr@) Differential Revision: pkill(1): Add EXAMPLES section to man page Modified: head/bin/pkill/pkill.1 Modified: head/bin/pkill/pkill.1 ============================================================================== --- head/bin/pkill/pkill.1 Mon Oct 5 13:49:45 2020 (r366447) +++ head/bin/pkill/pkill.1 Mon Oct 5 13:52:31 2020 (r366448) @@ -29,7 +29,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd December 3, 2018 +.Dd October 5, 2020 .Dt PKILL 1 .Os .Sh NAME @@ -270,6 +270,111 @@ Invalid options were specified on the command line. .It 3 An internal error occurred. .El +.Sh EXAMPLES +Show the pid of the process holding the +.Pa /tmp/.X0-lock +pid file: +.Bd -literal -offset indent +$ pgrep -F /tmp/.X0-lock +1211 +.Ed +.Pp +Show the pid and the name of the process including kernel threads in the +search: +.Bd -literal -offset indent +$ pgrep -lS vnlru +37 vnlru +.Ed +.Pp +Search for processes including kernel threads that match the extended regular +expression pattern: +.Bd -literal -offset indent +$ pgrep -S 'crypto.*[2-3]' +20 +19 +6 +5 +.Ed +.Pp +Show long output for firefox processes: +.Bd -literal -offset indent +$ pgrep -l firefox +1312 firefox +1309 firefox +1288 firefox +1280 firefox +1279 firefox +1278 firefox +1277 firefox +1264 firefox +.Ed +.Pp +Same as above but just showing the pid of the most recent process: +.Bd -literal -offset indent +$ pgrep -n firefox +1312 +.Ed +.Pp +Look for vim processes. +Match against the full argument list: +.Bd -literal -offset indent +$ pgrep -f vim +44968 +30790 +.Ed +.Pp +Same as above but matching against the +.Ql list +word and showing the full argument list: +.Bd -literal -offset indent +$ pgrep -f -l list +30790 vim list.txt +.Ed +.Pp +Send +.Va SIGSTOP +signal to processes that are an exact match: +.Bd -literal -offset indent +$ pkill -SIGSTOP -f -x "vim list.txt" +.Ed +.Pp +Without +.Fl f +names over 19 characters will silently fail: +.Bd -literal -offset indent +$ vim this_is_a_very_long_file_name & +[1] 36689 +$ + +[1]+ Stopped vim this_is_a_very_long_file_name +$ pgrep "vim this" +$ +.Ed +.Pp +Same as above using the +.Fl f +flag: +.Bd -literal -offset indent +$ pgrep -f "vim this" +36689 +.Ed +.Pp +Find the +.Xr top 1 +command running in any jail: +.Bd -literal -offset indent +$ pgrep -j any top +34498 +.Ed +.Pp +Show all processes running in jail ID 58: +.Bd -literal -offset indent +$ pgrep -l -j58 '.*' +28397 pkg-static +28396 pkg-static +28255 sh +28254 make +.Ed .Sh COMPATIBILITY Historically the option .Dq Fl j Li 0