1 .\" $NetBSD: pkill.1,v 1.8 2003/02/14 15:59:18 grant Exp $
5 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
6 .\" All rights reserved.
8 .\" This code is derived from software contributed to The NetBSD Foundation
11 .\" Redistribution and use in source and binary forms, with or without
12 .\" modification, are permitted provided that the following conditions
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.
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.
37 .Nd find or signal processes by name
74 command searches the process table on the running system and prints the
75 process IDs of all processes that match the criteria given on the command
80 command searches the process table on the running system and signals all
81 processes that match the criteria given on the command line.
83 The following options are available:
84 .Bl -tag -width ".Fl F Ar pidfile"
86 Restrict matches to a process whose PID is stored in the
90 Restrict matches to processes with a real group ID in the comma-separated
94 Request confirmation before attempting to signal each process.
100 option must be locked with the
102 syscall or created with
105 Extract values associated with the name list from the specified core
106 instead of the currently running system.
108 Extract the name list from the specified system instead of the default,
109 which is the kernel image the system has booted from.
111 Restrict matches to processes with a parent process ID in the
115 Search also in system processes (kernel threads).
117 Restrict matches to processes with a real user ID in the comma-separated
121 Specify a delimiter to be printed between each process ID.
122 The default is a newline.
123 This option can only be used with the
127 Include process ancestors in the match list.
128 By default, the current
132 process and all of its ancestors are excluded (unless
136 Restrict matches to processes running with specified login class
139 Match against full argument lists.
140 The default is to match against process names.
142 Restrict matches to processes with a process group ID in the comma-separated
145 The value zero is taken to mean the process group ID of the running
151 Ignore case distinctions in both the process table and the supplied pattern.
153 Restrict matches to processes inside the specified jails.
158 to match processes in any jail,
160 to match processes not in jail,
161 or a comma-separated list of jail IDs or names.
166 print the process name in addition to the process ID for each matching
168 If used in conjunction with
170 print the process ID and the full argument list for each matching process.
173 display the kill command used for each process killed.
175 Select only the newest (most recently started) of the matching processes.
177 Select only the oldest (least recently started) of the matching processes.
181 Do not write anything to standard output.
183 Restrict matches to processes with a session ID in the comma-separated
186 The value zero is taken to mean the session ID of the running
192 Restrict matches to processes associated with a terminal in the
195 Terminal names may be of the form
197 or the shortened form
201 matches processes not associated with a terminal.
203 Restrict matches to processes with an effective user ID in the
207 Reverse the sense of the matching; display processes that do not match the
210 Require an exact match of the process name, or argument list if
213 The default is to match any substring.
215 A non-negative decimal number or symbolic signal name specifying the signal
216 to be sent instead of the default
218 This option is valid only when given as the first argument to
224 operands are specified, they are used as extended regular expressions to match
225 the command name or full argument list of each process.
228 option is not specified, then the
230 will attempt to match the command name.
233 will only keep track of the first 19 characters of the command
234 name for each process.
235 Attempts to match any characters after the first 19 of a command name
242 process will never consider itself nor system processes (kernel threads) as
244 .Sh IMPLEMENTATION NOTES
245 The Sun Solaris implementation utilised procfs to obtain process information.
246 This implementation utilises
253 MIB to obtain the list of processes, kernel memory through
262 return one of the following values upon exit:
263 .Bl -tag -width indent
265 One or more processes were matched.
267 No processes were matched.
269 Invalid options were specified on the command line.
271 An internal error occurred.
274 Show the pid of the process holding the
277 .Bd -literal -offset indent
278 $ pgrep -F /tmp/.X0-lock
282 Show the pid and the name of the process including kernel threads in the
284 .Bd -literal -offset indent
289 Search for processes including kernel threads that match the extended regular
291 .Bd -literal -offset indent
292 $ pgrep -S 'crypto.*[2-3]'
299 Show long output for firefox processes:
300 .Bd -literal -offset indent
312 Same as above but just showing the pid of the most recent process:
313 .Bd -literal -offset indent
318 Look for vim processes.
319 Match against the full argument list:
320 .Bd -literal -offset indent
326 Same as above but matching against the
328 word and showing the full argument list:
329 .Bd -literal -offset indent
336 signal to processes that are an exact match:
337 .Bd -literal -offset indent
338 $ pkill -SIGSTOP -f -x "vim list.txt"
343 names over 19 characters will silently fail:
344 .Bd -literal -offset indent
345 $ vim this_is_a_very_long_file_name &
349 [1]+ Stopped vim this_is_a_very_long_file_name
354 Same as above using the
357 .Bd -literal -offset indent
358 $ pgrep -f "vim this"
364 command running in any jail:
365 .Bd -literal -offset indent
370 Show all processes running in jail ID 58:
371 .Bd -literal -offset indent
379 Historically the option
381 means any jail, although in other utilities such as
385 has the opposite meaning, not in jail.
388 is deprecated, and its use is discouraged in favor of
409 They are modelled after utilities of the same name that appeared in Sun
411 They made their first appearance in
414 .An Andrew Doran Aq Mt ad@NetBSD.org