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