1.\" $OpenBSD: pkill.1,v 1.7 2005/07/16 11:58:10 jmc Exp $ 2.\" $NetBSD: pkill.1,v 1.8 2003/02/14 15:59:18 grant Exp $ 3.\" 4.\" Copyright (c) 2002 The NetBSD Foundation, Inc. 5.\" All rights reserved. 6.\" 7.\" This code is derived from software contributed to The NetBSD Foundation 8.\" by Andrew Doran. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 3. All advertising materials mentioning features or use of this software 19.\" must display the following acknowledgement: 20.\" This product includes software developed by the NetBSD 21.\" Foundation, Inc. and its contributors. 22.\" 4. Neither the name of The NetBSD Foundation nor the names of its 23.\" contributors may be used to endorse or promote products derived 24.\" from this software without specific prior written permission. 25.\" 26.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36.\" POSSIBILITY OF SUCH DAMAGE. 37.\" 38.Dd March 1, 2002 39.Dt PKILL 1 40.Os 41.Sh NAME 42.Nm pgrep , pkill 43.Nd find or signal processes by name 44.Sh SYNOPSIS 45.Nm pgrep 46.Op Fl flnvx 47.Op Fl d Ar delim 48.Op Fl G Ar gid 49.Op Fl g Ar pgrp 50.Op Fl P Ar ppid 51.Op Fl s Ar sid 52.Op Fl t Ar tty 53.Op Fl U Ar uid 54.Op Fl u Ar euid 55.Op Ar pattern ... 56.Nm pkill 57.Op Fl signal 58.Op Fl fnvx 59.Op Fl G Ar gid 60.Op Fl g Ar pgrp 61.Op Fl P Ar ppid 62.Op Fl s Ar sid 63.Op Fl t Ar tty 64.Op Fl U Ar uid 65.Op Fl u Ar euid 66.Op Ar pattern ... 67.Sh DESCRIPTION 68The 69.Nm pgrep 70command searches the process table on the running system and prints the 71process IDs of all processes that match the criteria given on the command 72line. 73.Pp 74The 75.Nm pkill 76command searches the process table on the running system and signals all 77processes that match the criteria given on the command line. 78.Pp 79The following options are available: 80.Bl -tag -width Ds 81.It Fl d Ar delim 82Specify a delimiter to be printed between each process ID. 83The default is a newline. 84This option can only be used with the 85.Nm pgrep 86command. 87.It Fl f 88Match against full argument lists. 89The default is to match against process names. 90.It Fl G Ar gid 91Restrict matches to processes with a real group ID in the comma-separated 92list 93.Ar gid . 94.It Fl g Ar pgrp 95Restrict matches to processes with a process group ID in the comma-separated 96list 97.Ar pgrp . 98The value zero is taken to mean the process group ID of the running 99.Nm pgrep 100or 101.Nm pkill 102command. 103.It Fl l 104Long output. 105Print the process name in addition to the process ID for each matching 106process. 107If used in conjunction with 108.Fl f , 109print the process ID and the full argument list for each matching process. 110This option can only be used with the 111.Nm pgrep 112command. 113.It Fl n 114Match only the most recently created process, if any. 115.It Fl P Ar ppid 116Restrict matches to processes with a parent process ID in the 117comma-separated list 118.Ar ppid . 119.It Fl s Ar sid 120Restrict matches to processes with a session ID in the comma-separated 121list 122.Ar sid . 123The value zero is taken to mean the session ID of the running 124.Nm pgrep 125or 126.Nm pkill 127command. 128.It Fl t Ar tty 129Restrict matches to processes associated with a terminal in the 130comma-separated list 131.Ar tty . 132Terminal names may be of the form 133.Sq ttyxx 134or the shortened form 135.Sq xx . 136A single dash 137.Pq Sq - 138matches processes not associated with a terminal. 139.It Fl U Ar uid 140Restrict matches to processes with a real user ID in the comma-separated 141list 142.Ar uid . 143.It Fl u Ar euid 144Restrict matches to processes with an effective user ID in the 145comma-separated list 146.Ar euid . 147.It Fl v 148Reverse the sense of the matching; display processes that do not match the 149given criteria. 150.It Fl x 151Require an exact match of the process name, or argument list if 152.Fl f 153is given. 154The default is to match any substring. 155.It Fl signal 156A non-negative decimal number or symbolic signal name specifying the signal 157to be sent instead of the default TERM. 158This option is valid only when given as the first argument to 159.Nm pkill . 160.El 161.Pp 162Note that a running 163.Nm pgrep 164or 165.Nm pkill 166process will never consider itself or system processes (kernel threads) as 167a potential match. 168.Pp 169.Nm pgrep 170and 171.Nm pkill 172return one of the following values upon exit: 173.Pp 174.Bl -tag -width Ds -offset indent -compact 175.It 0 176One or more processes were matched. 177.It 1 178No processes were matched. 179.It 2 180Invalid options were specified on the command line. 181.It 3 182An internal error occurred. 183.El 184.Sh SEE ALSO 185.Xr grep 1 , 186.Xr kill 1 , 187.Xr ps 1 , 188.Xr kill 2 , 189.Xr sigaction 2 , 190.Xr re_format 7 191.Sh HISTORY 192.Nm pkill 193and 194.Nm pgrep 195first appeared in 196.Ox 3.5 . 197They are modelled after utilities of the same name that appeared in Sun 198Solaris 7. 199.Sh AUTHORS 200.An Andrew Doran 201.Aq ad@NetBSD.org . 202