Commit | Line | Data |
---|---|---|
df558cd9 | 1 | .\" $NetBSD: pkill.1,v 1.8 2003/02/14 15:59:18 grant Exp $ |
df558cd9 | 2 | .\" |
65a0e3d6 JM |
3 | .\" $FreeBSD: head/bin/pkill/pkill.1 254134 2013-08-09 08:38:51Z trasz $ |
4 | .\" | |
df558cd9 CP |
5 | .\" Copyright (c) 2002 The NetBSD Foundation, Inc. |
6 | .\" All rights reserved. | |
7 | .\" | |
8 | .\" This code is derived from software contributed to The NetBSD Foundation | |
9 | .\" by Andrew Doran. | |
10 | .\" | |
11 | .\" Redistribution and use in source and binary forms, with or without | |
12 | .\" modification, are permitted provided that the following conditions | |
13 | .\" are met: | |
14 | .\" 1. Redistributions of source code must retain the above copyright | |
15 | .\" notice, this list of conditions and the following disclaimer. | |
16 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
17 | .\" notice, this list of conditions and the following disclaimer in the | |
18 | .\" documentation and/or other materials provided with the distribution. | |
df558cd9 CP |
19 | .\" |
20 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
21 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
22 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
23 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
24 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
25 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | .\" POSSIBILITY OF SUCH DAMAGE. | |
31 | .\" | |
600b1034 | 32 | .Dd January 7, 2023 |
df558cd9 CP |
33 | .Dt PKILL 1 |
34 | .Os | |
35 | .Sh NAME | |
5f0cb5a0 FF |
36 | .Nm pgrep , |
37 | .Nm pkill | |
df558cd9 CP |
38 | .Nd find or signal processes by name |
39 | .Sh SYNOPSIS | |
40 | .Nm pgrep | |
a2d71d01 | 41 | .Op Fl LSTafilnoqvx |
65a0e3d6 | 42 | .Op Fl F Ar pidfile |
df558cd9 | 43 | .Op Fl G Ar gid |
65a0e3d6 JM |
44 | .Op Fl M Ar core |
45 | .Op Fl N Ar system | |
df558cd9 CP |
46 | .Op Fl P Ar ppid |
47 | .Op Fl U Ar uid | |
65a0e3d6 | 48 | .Op Fl c Ar class |
df558cd9 CP |
49 | .Op Fl d Ar delim |
50 | .Op Fl g Ar pgrp | |
65a0e3d6 | 51 | .Op Fl j Ar jid |
df558cd9 CP |
52 | .Op Fl s Ar sid |
53 | .Op Fl t Ar tty | |
54 | .Op Fl u Ar euid | |
65a0e3d6 | 55 | .Ar pattern ... |
df558cd9 | 56 | .Nm pkill |
65a0e3d6 | 57 | .Op Fl Ar signal |
a2d71d01 | 58 | .Op Fl ILTafilnovx |
65a0e3d6 | 59 | .Op Fl F Ar pidfile |
df558cd9 | 60 | .Op Fl G Ar gid |
65a0e3d6 JM |
61 | .Op Fl M Ar core |
62 | .Op Fl N Ar system | |
df558cd9 CP |
63 | .Op Fl P Ar ppid |
64 | .Op Fl U Ar uid | |
65a0e3d6 | 65 | .Op Fl c Ar class |
df558cd9 | 66 | .Op Fl g Ar pgrp |
65a0e3d6 | 67 | .Op Fl j Ar jid |
df558cd9 CP |
68 | .Op Fl s Ar sid |
69 | .Op Fl t Ar tty | |
70 | .Op Fl u Ar euid | |
65a0e3d6 | 71 | .Ar pattern ... |
df558cd9 CP |
72 | .Sh DESCRIPTION |
73 | The | |
74 | .Nm pgrep | |
75 | command searches the process table on the running system and prints the | |
76 | process IDs of all processes that match the criteria given on the command | |
77 | line. | |
78 | .Pp | |
79 | The | |
80 | .Nm pkill | |
81 | command searches the process table on the running system and signals all | |
82 | processes that match the criteria given on the command line. | |
83 | .Pp | |
84 | The following options are available: | |
65a0e3d6 JM |
85 | .Bl -tag -width ".Fl F Ar pidfile" |
86 | .It Fl F Ar pidfile | |
87 | Restrict matches to a process whose PID is stored in the | |
88 | .Ar pidfile | |
89 | file. | |
df558cd9 CP |
90 | .It Fl G Ar gid |
91 | Restrict matches to processes with a real group ID in the comma-separated | |
92 | list | |
93 | .Ar gid . | |
65a0e3d6 JM |
94 | .It Fl I |
95 | Request confirmation before attempting to signal each process. | |
96 | .It Fl L | |
97 | The | |
98 | .Ar pidfile | |
99 | file given for the | |
100 | .Fl F | |
101 | option must be locked with the | |
102 | .Xr flock 2 | |
103 | syscall or created with | |
104 | .Xr pidfile 3 . | |
105 | .It Fl M Ar core | |
106 | Extract values associated with the name list from the specified core | |
107 | instead of the currently running system. | |
108 | .It Fl N Ar system | |
109 | Extract the name list from the specified system instead of the default, | |
110 | which is the kernel image the system has booted from. | |
df558cd9 CP |
111 | .It Fl P Ar ppid |
112 | Restrict matches to processes with a parent process ID in the | |
113 | comma-separated list | |
114 | .Ar ppid . | |
65a0e3d6 JM |
115 | .It Fl S |
116 | Search also in system processes (kernel threads). | |
a2d71d01 LK |
117 | .It Fl T |
118 | Restrict matches to processes associated with the current terminal. | |
df558cd9 CP |
119 | .It Fl U Ar uid |
120 | Restrict matches to processes with a real user ID in the comma-separated | |
121 | list | |
122 | .Ar uid . | |
65a0e3d6 JM |
123 | .It Fl a |
124 | Include process ancestors in the match list. | |
125 | By default, the current | |
126 | .Nm pgrep | |
127 | or | |
128 | .Nm pkill | |
129 | process and all of its ancestors are excluded (unless | |
130 | .Fl v | |
131 | is used). | |
132 | .It Fl c Ar class | |
133 | Restrict matches to processes running with specified login class | |
134 | .Ar class . | |
a2d71d01 LK |
135 | .It Fl d Ar delim |
136 | Specify a delimiter to be printed between each process ID. | |
137 | The default is a newline. | |
138 | This option can only be used with the | |
139 | .Nm pgrep | |
140 | command. | |
df558cd9 CP |
141 | .It Fl f |
142 | Match against full argument lists. | |
143 | The default is to match against process names. | |
144 | .It Fl g Ar pgrp | |
145 | Restrict matches to processes with a process group ID in the comma-separated | |
146 | list | |
147 | .Ar pgrp . | |
148 | The value zero is taken to mean the process group ID of the running | |
149 | .Nm pgrep | |
150 | or | |
151 | .Nm pkill | |
152 | command. | |
65a0e3d6 JM |
153 | .It Fl i |
154 | Ignore case distinctions in both the process table and the supplied pattern. | |
54499c33 CT |
155 | .It Fl j Ar jid |
156 | Restrict matches to processes inside jails with a jail ID in the comma-separated | |
157 | list | |
158 | .Ar jid . | |
159 | The value | |
65a0e3d6 | 160 | .Dq Li any |
54499c33 CT |
161 | matches processes in any jail. |
162 | The value | |
65a0e3d6 JM |
163 | .Dq Li none |
164 | matches processes not in jail. | |
df558cd9 CP |
165 | .It Fl l |
166 | Long output. | |
65a0e3d6 JM |
167 | For |
168 | .Nm pgrep , | |
169 | print the process name in addition to the process ID for each matching | |
df558cd9 CP |
170 | process. |
171 | If used in conjunction with | |
172 | .Fl f , | |
173 | print the process ID and the full argument list for each matching process. | |
65a0e3d6 JM |
174 | For |
175 | .Nm pkill , | |
176 | display the kill command used for each process killed. | |
df558cd9 | 177 | .It Fl n |
65a0e3d6 JM |
178 | Select only the newest (most recently started) of the matching processes. |
179 | .It Fl o | |
180 | Select only the oldest (least recently started) of the matching processes. | |
181 | .It Fl q | |
182 | Do not write anything to standard output. | |
df558cd9 CP |
183 | .It Fl s Ar sid |
184 | Restrict matches to processes with a session ID in the comma-separated | |
185 | list | |
186 | .Ar sid . | |
187 | The value zero is taken to mean the session ID of the running | |
188 | .Nm pgrep | |
189 | or | |
190 | .Nm pkill | |
191 | command. | |
192 | .It Fl t Ar tty | |
193 | Restrict matches to processes associated with a terminal in the | |
194 | comma-separated list | |
195 | .Ar tty . | |
196 | Terminal names may be of the form | |
a2d71d01 LK |
197 | .Pa tty Ns Ar xx , |
198 | the full path form | |
199 | .Pa /dev/tty Ns Ar xx , | |
df558cd9 | 200 | or the shortened form |
65a0e3d6 | 201 | .Ar xx . |
a2d71d01 LK |
202 | For pseudo terminals, use |
203 | .Pa pts/ Ns Ar xx , | |
204 | .Pa /dev/pts/ Ns Ar xx , | |
205 | or | |
206 | .Ar xx | |
207 | as the name. | |
65a0e3d6 JM |
208 | A single dash |
209 | .Pq Ql - | |
210 | matches processes not associated with a terminal. | |
df558cd9 CP |
211 | .It Fl u Ar euid |
212 | Restrict matches to processes with an effective user ID in the | |
213 | comma-separated list | |
214 | .Ar euid . | |
215 | .It Fl v | |
216 | Reverse the sense of the matching; display processes that do not match the | |
217 | given criteria. | |
218 | .It Fl x | |
219 | Require an exact match of the process name, or argument list if | |
220 | .Fl f | |
221 | is given. | |
222 | The default is to match any substring. | |
65a0e3d6 | 223 | .It Fl Ns Ar signal |
df558cd9 | 224 | A non-negative decimal number or symbolic signal name specifying the signal |
65a0e3d6 JM |
225 | to be sent instead of the default |
226 | .Dv TERM . | |
df558cd9 CP |
227 | This option is valid only when given as the first argument to |
228 | .Nm pkill . | |
229 | .El | |
230 | .Pp | |
65a0e3d6 JM |
231 | If any |
232 | .Ar pattern | |
233 | operands are specified, they are used as regular expressions to match | |
234 | the command name or full argument list of each process. | |
235 | If the | |
236 | .Fl f | |
237 | option is not specified, then the | |
238 | .Ar pattern | |
239 | will attempt to match the command name. | |
240 | However, presently | |
241 | .Fx | |
242 | will only keep track of the first 19 characters of the command | |
243 | name for each process. | |
244 | Attempts to match any characters after the first 19 of a command name | |
245 | will quietly fail. | |
246 | .Pp | |
df558cd9 CP |
247 | Note that a running |
248 | .Nm pgrep | |
249 | or | |
250 | .Nm pkill | |
251 | process will never consider itself nor system processes (kernel threads) as | |
252 | a potential match. | |
600b1034 SW |
253 | .Sh IMPLEMENTATION NOTES |
254 | The Sun Solaris implementation utilised procfs to obtain process information. | |
255 | This implementation utilises | |
256 | .Xr kvm 3 | |
257 | instead. | |
258 | On a live system, | |
259 | .Xr kvm 3 | |
260 | uses the | |
261 | .Va kern.proc | |
262 | MIB to obtain the list of processes. | |
263 | Kernel memory through | |
264 | .Pa /dev/kmem | |
265 | is not accessed. | |
65a0e3d6 JM |
266 | .Sh EXIT STATUS |
267 | The | |
df558cd9 CP |
268 | .Nm pgrep |
269 | and | |
270 | .Nm pkill | |
65a0e3d6 | 271 | utilities |
df558cd9 | 272 | return one of the following values upon exit: |
65a0e3d6 | 273 | .Bl -tag -width indent |
df558cd9 CP |
274 | .It 0 |
275 | One or more processes were matched. | |
276 | .It 1 | |
277 | No processes were matched. | |
278 | .It 2 | |
279 | Invalid options were specified on the command line. | |
280 | .It 3 | |
281 | An internal error occurred. | |
282 | .El | |
65a0e3d6 JM |
283 | .Sh COMPATIBILITY |
284 | Historically the option | |
285 | .Dq Fl j Li 0 | |
286 | means any jail, although in other utilities such as | |
287 | .Xr ps 1 | |
288 | jail ID | |
289 | .Li 0 | |
290 | has the opposite meaning, not in jail. | |
291 | Therefore | |
292 | .Dq Fl j Li 0 | |
293 | is deprecated, and its use is discouraged in favor of | |
294 | .Dq Fl j Li any . | |
df558cd9 CP |
295 | .Sh SEE ALSO |
296 | .Xr kill 1 , | |
65a0e3d6 | 297 | .Xr killall 1 , |
df558cd9 | 298 | .Xr ps 1 , |
65a0e3d6 | 299 | .Xr flock 2 , |
df558cd9 CP |
300 | .Xr kill 2 , |
301 | .Xr sigaction 2 , | |
65a0e3d6 | 302 | .Xr pidfile 3 , |
cbef4fde | 303 | .Xr signal 3 , |
302e0891 | 304 | .Xr re_format 7 |
df558cd9 | 305 | .Sh HISTORY |
65a0e3d6 | 306 | The |
df558cd9 CP |
307 | .Nm pkill |
308 | and | |
309 | .Nm pgrep | |
65a0e3d6 | 310 | utilities |
cbef4fde | 311 | originated in |
df558cd9 | 312 | .Nx 1.6 . |
65a0e3d6 | 313 | They are modelled after utilities of the same name that appeared in Sun |
df558cd9 | 314 | Solaris 7. |
4e3518d8 | 315 | They first appeared in |
5f0cb5a0 | 316 | .Dx 1.1 . |
df558cd9 | 317 | .Sh AUTHORS |
b4f25088 | 318 | .An Andrew Doran Aq Mt ad@NetBSD.org |