xref: /openbsd-src/usr.bin/pkill/pkill.1 (revision 2b0358df1d88d06ef4139321dd05bd5e05d91eaf)
1.\"	$OpenBSD: pkill.1,v 1.13 2009/03/26 08:38:39 sobrado 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: March 26 2009 $
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; display processes that do not match the
148given 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
161Note that a running
162.Nm pgrep
163or
164.Nm pkill
165process will never consider itself or system processes (kernel threads) as
166a potential match.
167.Pp
168.Nm pgrep
169and
170.Nm pkill
171return one of the following values upon exit:
172.Pp
173.Bl -tag -width Ds -offset indent -compact
174.It 0
175One or more processes were matched.
176.It 1
177No processes were matched.
178.It 2
179Invalid options were specified on the command line.
180.It 3
181An internal error occurred.
182.El
183.Sh SEE ALSO
184.Xr grep 1 ,
185.Xr kill 1 ,
186.Xr ps 1 ,
187.Xr kill 2 ,
188.Xr sigaction 2 ,
189.Xr re_format 7
190.Sh HISTORY
191.Nm pkill
192and
193.Nm pgrep
194first appeared in
195.Ox 3.5 .
196They are modelled after utilities of the same name that appeared in Sun
197Solaris 7.
198.Sh AUTHORS
199.An Andrew Doran
200.Aq ad@NetBSD.org .
201