xref: /netbsd/usr.bin/pkill/pkill.1 (revision 6550d01e)
1.\"	$NetBSD: pkill.1,v 1.23 2010/12/07 09:00:23 enami 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 December 7, 2010
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
80The following options are available for
81.Nm pkill
82and
83.Nm pgrep :
84.Bl -tag -width xxxxxxxx
85.It Fl d Ar delim
86Specify a delimiter to be printed between each process ID.
87The default is a newline.
88This option can only be used with the
89.Nm pgrep
90command.
91.It Fl f
92Match against full argument lists.
93The default is to match against process names.
94.It Fl G Ar gid
95Restrict matches to processes with a real group ID in the comma-separated
96list
97.Ar gid .
98.It Fl g Ar pgrp
99Restrict matches to processes with a process group ID in the comma-separated
100list
101.Ar pgrp .
102The value zero is taken to mean the process group ID of the running
103.Nm pgrep
104or
105.Nm pkill
106command.
107.It Fl i
108Ignore case distinctions in both the process table and the supplied pattern.
109.It Fl l
110Long output.
111Print the process name in addition to the process ID for each matching
112process.
113If used in conjunction with
114.Fl f ,
115print the process ID and the full argument list for each matching process.
116.It Fl n
117Match only the most recently created process, if any.
118.It Fl P Ar ppid
119Restrict matches to processes with a parent process ID in the
120comma-separated list
121.Ar ppid .
122.It Fl s Ar sid
123Restrict matches to processes with a session ID in the comma-separated
124list
125.Ar sid .
126The value zero is taken to mean the session ID of the running
127.Nm pgrep
128or
129.Nm pkill
130command.
131.It Fl t Ar tty
132Restrict matches to processes associated with a terminal in the
133comma-separated list
134.Ar tty .
135Terminal names may be specified as a fully qualified path, in the form
136.Sq ttyXX ,
137or
138.Sq pts/N ,
139(where
140.Ar XX
141is any pair of letters, and
142.Ar N
143is a number),
144or the shortened forms
145.Sq XX
146or
147.Sq N .
148A single dash
149.Pq Sq -
150matches processes not associated with a terminal.
151.It Fl U Ar uid
152Restrict matches to processes with a real user ID in the comma-separated
153list
154.Ar uid .
155.It Fl u Ar euid
156Restrict matches to processes with an effective user ID in the
157comma-separated list
158.Ar euid .
159.It Fl v
160Reverse the sense of the matching; display processes that do not match the
161given criteria.
162.It Fl x
163Require an exact match of the process name, or argument list if
164.Fl f
165is given.
166The default is to match any substring.
167.It Fl signal
168A non-negative decimal number or symbolic signal name specifying the signal
169to be sent instead of the default TERM.
170This option is valid only when given as the first argument to
171.Nm pkill .
172.El
173.Pp
174The
175.Fl l
176flag is also availale for
177.Nm prenice .
178.Pp
179Note that a running
180.Nm pgrep
181or
182.Nm pkill
183process will never consider itself or system processes (kernel threads) as
184a potential match.
185.Sh EXIT STATUS
186.Nm pgrep ,
187.Nm pkill ,
188and
189.Nm prenice
190return one of the following values upon exit:
191.Bl -tag -width foo
192.It 0
193One or more processes were matched.
194.It 1
195No processes were matched.
196.It 2
197Invalid options were specified on the command line.
198.It 3
199An internal error occurred.
200.El
201.Sh SEE ALSO
202.Xr grep 1 ,
203.Xr kill 1 ,
204.Xr ps 1 ,
205.Xr kill 2 ,
206.Xr sigaction 2 ,
207.Xr re_format 7 ,
208.Xr signal 7 ,
209.Xr renice 8
210.Sh HISTORY
211.Nm pkill
212and
213.Nm pgrep
214first appeared in
215.Nx 1.6 .
216They are modelled after utilities of the same name that appeared in Sun
217Solaris 7.
218.Pp
219.Nm prenice
220was introduced in
221.Nx 6.0 .
222