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