xref: /netbsd-src/usr.bin/pkill/pkill.1 (revision ccd9df534e375a4366c5b55f23782053c7a98d82)
1.\"	$NetBSD: pkill.1,v 1.32 2022/10/29 08:17:16 simonb 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 October 29, 2022
31.Dt PKILL 1
32.Os
33.Sh NAME
34.Nm pkill ,
35.Nm pgrep ,
36.Nm prenice
37.Nd find or signal processes by name
38.Sh SYNOPSIS
39.Nm pgrep
40.Op Fl filnqvx
41.Op Fl d Ar delim
42.Op Fl G Ar gid
43.Op Fl g Ar pgrp
44.Op Fl P Ar ppid
45.Op Fl s Ar sid
46.Op Fl t Ar tty
47.Op Fl U Ar uid
48.Op Fl u Ar euid
49.Ar pattern ...
50.Nm pkill
51.Op Fl signal
52.Op Fl filnvx
53.Op Fl G Ar gid
54.Op Fl g Ar pgrp
55.Op Fl P Ar ppid
56.Op Fl s Ar sid
57.Op Fl t Ar tty
58.Op Fl U Ar uid
59.Op Fl u Ar euid
60.Ar pattern ...
61.Nm prenice
62.Op Fl l
63.Ar priority
64.Ar pattern ...
65.Sh DESCRIPTION
66The
67.Nm pgrep
68command searches the process table on the running system and prints the
69process IDs of all processes that match the criteria given on the command
70line.
71.Pp
72The
73.Nm pkill
74command searches the process table on the running system and signals all
75processes that match the criteria given on the command line.
76.Pp
77The
78.Nm prenice
79command searches the process table on the running system and sets the
80priority of all processes that match the criteria given on the command line.
81.Pp
82By default, matching applies to any substring of the command name
83.Pq Va argv[0] ,
84but options may be used to change this.
85Patterns are specified using extended regular expressions (see
86.Xr re_format 7 ) .
87.Pp
88The following options are available for
89.Nm pkill
90and
91.Nm pgrep :
92.Bl -tag -width xxxxxxxx
93.It Fl d Ar delim
94Specify a delimiter to be printed between each process ID.
95The default is a newline.
96This option can only be used with the
97.Nm pgrep
98command.
99.It Fl f
100Match against full argument lists.
101The default is to match against process names.
102.It Fl G Ar gid
103Restrict matches to processes with a real group ID in the comma-separated
104list
105.Ar gid .
106.It Fl g Ar pgrp
107Restrict matches to processes with a process group ID in the comma-separated
108list
109.Ar pgrp .
110The value zero is taken to mean the process group ID of the running
111.Nm pgrep
112or
113.Nm pkill
114command.
115.It Fl i
116Ignore case distinctions in both the process table and the supplied pattern.
117.It Fl l
118Long output.
119Print the process name in addition to the process ID for each matching
120process.
121If used in conjunction with
122.Fl f ,
123print the process ID and the full argument list for each matching process.
124.It Fl n
125Match only the most recently created process, if any.
126.It Fl P Ar ppid
127Restrict matches to processes with a parent process ID in the
128comma-separated list
129.Ar ppid .
130.It Fl s Ar sid
131Restrict matches to processes with a session ID in the comma-separated
132list
133.Ar sid .
134The value zero is taken to mean the session ID of the running
135.Nm pgrep
136or
137.Nm pkill
138command.
139.It Fl t Ar tty
140Restrict matches to processes associated with a terminal in the
141comma-separated list
142.Ar tty .
143Terminal names may be specified as a fully qualified path, in the form
144.Sq ttyXX ,
145or
146.Sq pts/N ,
147(where
148.Ar XX
149is any pair of letters, and
150.Ar N
151is a number),
152or the shortened forms
153.Sq XX
154or
155.Sq N .
156A single dash
157.Pq Sq -
158matches processes not associated with a terminal.
159.It Fl U Ar uid
160Restrict matches to processes with a real user ID in the comma-separated
161list
162.Ar uid .
163.It Fl u Ar euid
164Restrict matches to processes with an effective user ID in the
165comma-separated list
166.Ar euid .
167.It Fl v
168Reverse the sense of the matching; display processes that do not match the
169given criteria.
170.It Fl x
171Require an exact match of the process name, or argument list if
172.Fl f
173is given.
174The default is to match any substring.
175.It Fl signal
176A non-negative decimal number or symbolic signal name specifying the signal
177to be sent instead of the default TERM.
178This option is valid only when given as the first argument to
179.Nm pkill .
180.El
181.Pp
182The following option is also available for
183.Nm pgrep :
184.Bl -tag -width xxxxxxxx
185.It Fl q
186Quiet; do not write anything to standard output.
187.El
188.Pp
189The
190.Fl l
191flag is also available for
192.Nm prenice .
193.Pp
194Note that a running
195.Nm pgrep ,
196.Nm pkill ,
197or
198.Nm prenice
199process will never consider itself or system processes (kernel threads) as
200a potential match.
201.Sh IMPLEMENTATION NOTES
202The Sun Solaris implementation utilised procfs to obtain process information.
203This implementation utilises
204.Xr kvm 3
205instead.
206.Sh EXIT STATUS
207.Nm pgrep ,
208.Nm pkill ,
209and
210.Nm prenice
211return one of the following values upon exit:
212.Bl -tag -width foo
213.It 0
214One or more processes were matched.
215.It 1
216No processes were matched.
217.It 2
218Invalid options were specified on the command line.
219.It 3
220An internal error occurred.
221.El
222.Sh SEE ALSO
223.Xr grep 1 ,
224.Xr kill 1 ,
225.Xr ps 1 ,
226.Xr kill 2 ,
227.Xr sigaction 2 ,
228.Xr kvm 3 ,
229.Xr re_format 7 ,
230.Xr signal 7 ,
231.Xr renice 8
232.Sh HISTORY
233.Nm pkill
234and
235.Nm pgrep
236first appeared in
237.Nx 1.6 .
238They are modelled after utilities of the same name that appeared in Sun
239Solaris 7.
240.Pp
241.Nm prenice
242was introduced in
243.Nx 6.0 .
244.Sh AUTHORS
245.An Andrew Doran
246.Aq Mt ad@NetBSD.org .
247