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