Print this page
3563 pgrep not working as documented or documentation inaccurate
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man1/pgrep.1
+++ new/usr/src/man/man1/pgrep.1
1 1 '\" te
2 2 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved
3 3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 -.TH PGREP 1 "May 6, 2004"
6 +.TH PGREP 1 "Dec 30, 2013"
7 7 .SH NAME
8 8 pgrep, pkill \- find or signal processes by name and other attributes
9 9 .SH SYNOPSIS
10 10 .LP
11 11 .nf
12 12 \fBpgrep\fR [\fB-flvx\fR] [\fB-n\fR | \fB-o\fR] [\fB-d\fR \fIdelim\fR] [\fB-P\fR \fIppidlist\fR]
13 13 [\fB-g\fR \fIpgrplist\fR] [\fB-s\fR \fIsidlist\fR] [\fB-u\fR \fIeuidlist\fR] [\fB-U\fR \fIuidlist\fR]
14 14 [\fB-G\fR \fIgidlist\fR] [\fB-J\fR \fIprojidlist\fR] [\fB-t\fR \fItermlist\fR]
15 15 [\fB-T\fR \fItaskidlist\fR] [\fB-c\fR \fIctidlist\fR] [\fB-z\fR \fIzoneidlist\fR]
16 16 [\fIpattern\fR]
17 17 .fi
18 18
19 19 .LP
20 20 .nf
21 21 \fBpkill\fR [\fB-\fIsignal\fR\fR] [\fB-fvx\fR] [\fB-n\fR | \fB-o\fR] [\fB-P\fR \fIppidlist\fR]
22 22 [\fB-g\fR \fIpgrplist\fR] [\fB-s\fR \fIsidlist\fR] [\fB-u\fR \fIeuidlist\fR] [\fB-U\fR \fIuidlist\fR]
23 23 [\fB-G\fR \fIgidlist\fR] [\fB-J\fR \fIprojidlist\fR] [\fB-t\fR \fItermlist\fR]
24 24 [\fB-T\fR \fItaskidlist\fR] [\fB-c\fR \fIctidlist\fR] [\fB-z\fR \fIzoneidlist\fR]
25 25 [\fIpattern\fR]
26 26 .fi
27 27
28 28 .SH DESCRIPTION
29 29 .sp
30 30 .LP
31 31 The \fBpgrep\fR utility examines the active processes on the system and reports
32 32 the process \fBID\fRs of the processes whose attributes match the criteria
33 33 specified on the command line. Each process \fBID\fR is printed as a decimal
34 34 value and is separated from the next \fBID\fR by a delimiter string, which
35 35 defaults to a newline. For each attribute option, the user can specify a set of
36 36 possible values separated by commas on the command line. For example,
37 37 .sp
38 38 .in +2
39 39 .nf
40 40 \fBpgrep -G other,daemon\fR
41 41 .fi
42 42 .in -2
43 43 .sp
44 44
45 45 .sp
46 46 .LP
47 47 matches processes whose real group \fBID\fR is \fBother\fR \fBOR\fR
48 48 \fBdaemon\fR. If multiple criteria options are specified, \fBpgrep\fR matches
49 49 processes whose attributes match the logical \fBAND\fR of the criteria options.
50 50 For example,
51 51 .sp
52 52 .in +2
53 53 .nf
54 54 \fBpgrep -G other,daemon -U root,daemon\fR
55 55 .fi
56 56 .in -2
57 57 .sp
58 58
59 59 .sp
60 60 .LP
61 61 matches processes whose attributes are:
62 62 .br
63 63 .in +2
64 64 (real group \fBID\fR is \fBother\fR \fBOR\fR \fBdaemon\fR) \fBAND\fR
65 65 .in -2
66 66 .br
67 67 .in +2
68 68 (real user \fBID\fR is \fBroot\fR \fBOR\fR \fBdaemon\fR)
69 69 .in -2
70 70 .sp
71 71 .LP
72 72 \fBpkill\fR functions identically to \fBpgrep\fR, except that each matching
73 73 process is signaled as if by \fBkill\fR(1) instead of having its process
74 74 \fBID\fR printed. A signal name or number may be specified as the first command
75 75 line option to \fBpkill\fR.
76 76 .SH OPTIONS
77 77 .sp
78 78 .LP
79 79 The following options are supported:
80 80 .sp
81 81 .ne 2
82 82 .na
83 83 \fB\fB-c\fR \fIctidlist\fR\fR
84 84 .ad
85 85 .RS 17n
86 86 Matches only processes whose process contract ID is in the given list.
87 87 .RE
88 88
89 89 .sp
90 90 .ne 2
91 91 .na
92 92 \fB\fB-d\fR \fIdelim\fR\fR
93 93 .ad
94 94 .RS 17n
95 95 Specifies the output delimiter string to be printed between each matching
96 96 process \fBID\fR. If no \fB-d\fR option is specified, the default is a newline
97 97 character. The \fB-d\fR option is only valid when specified as an option to
98 98 \fBpgrep\fR.
99 99 .RE
100 100
101 101 .sp
102 102 .ne 2
103 103 .na
104 104 \fB\fB-f\fR\fR
105 105 .ad
106 106 .RS 17n
107 107 The regular expression \fIpattern\fR should be matched against the full process
108 108 argument string (obtained from the \fBpr_psargs\fR field of the
109 109 \fB/proc/\fInnnnn\fR/psinfo\fR file). If no \fB-f\fR option is specified, the
110 110 expression is matched only against the name of the executable file (obtained
111 111 from the \fBpr_fname\fR field of the \fB/proc/\fInnnnn\fR/psinfo\fR file).
112 112 .RE
113 113
114 114 .sp
115 115 .ne 2
116 116 .na
117 117 \fB\fB-g\fR \fIpgrplist\fR\fR
118 118 .ad
119 119 .RS 17n
120 120 Matches only processes whose process group \fBID\fR is in the given list. If
121 121 group 0 is included in the list, this is interpreted as the process group
122 122 \fBID\fR of the \fBpgrep\fR or \fBpkill\fR process.
123 123 .RE
124 124
125 125 .sp
126 126 .ne 2
127 127 .na
128 128 \fB\fB-G\fR \fIgidlist\fR\fR
129 129 .ad
130 130 .RS 17n
131 131 Matches only processes whose real group \fBID\fR is in the given list. Each
132 132 group \fBID\fR may be specified as either a group name or a numerical group
133 133 \fBID\fR.
134 134 .RE
135 135
136 136 .sp
137 137 .ne 2
138 138 .na
139 139 \fB\fB-J\fR \fIprojidlist\fR\fR
140 140 .ad
141 141 .RS 17n
142 142 Matches only processes whose project \fBID\fR is in the given list. Each
143 143 project \fBID\fR may be specified as either a project name or a numerical
144 144 project \fBID\fR.
145 145 .RE
146 146
147 147 .sp
148 148 .ne 2
149 149 .na
150 150 \fB\fB-l\fR\fR
151 151 .ad
152 152 .RS 17n
153 153 Long output format. Prints the process name along with the process \fBID\fR of
154 154 each matching process. The process name is obtained from the \fBpr_psargs\fR or
155 155 \fBpr_fname\fR field, depending on whether the \fB-f\fR option was specified
156 156 (see above). The \fB-l\fR option is only valid when specified as an option to
157 157 \fBpgrep\fR.
158 158 .RE
159 159
160 160 .sp
161 161 .ne 2
162 162 .na
163 163 \fB\fB-n\fR\fR
164 164 .ad
165 165 .RS 17n
166 166 Matches only the newest (most recently created) process that meets all other
167 167 specified matching criteria. Cannot be used with option \fB-o\fR.
168 168 .RE
169 169
170 170 .sp
171 171 .ne 2
172 172 .na
173 173 \fB\fB-o\fR\fR
174 174 .ad
175 175 .RS 17n
176 176 Matches only the oldest (earliest created) process that meets all other
177 177 specified matching criteria. Cannot be used with option \fB-n\fR.
178 178 .RE
179 179
180 180 .sp
181 181 .ne 2
182 182 .na
183 183 \fB\fB-P\fR \fIppidlist\fR\fR
184 184 .ad
185 185 .RS 17n
186 186 Matches only processes whose parent process \fBID\fR is in the given list.
187 187 .RE
188 188
189 189 .sp
190 190 .ne 2
191 191 .na
192 192 \fB\fB-s\fR \fIsidlist\fR\fR
193 193 .ad
194 194 .RS 17n
195 195 Matches only processes whose process session \fBID\fR is in in the given list.
196 196 If \fBID\fR 0 is included in the list, this is interpreted as the session
197 197 \fBID\fR of the \fBpgrep\fR or \fBpkill\fR process.
198 198 .RE
199 199
200 200 .sp
201 201 .ne 2
202 202 .na
203 203 \fB\fB-t\fR \fItermlist\fR\fR
204 204 .ad
205 205 .RS 17n
206 206 Matches only processes which are associated with a terminal in the given list.
207 207 Each terminal is specified as the suffix following "/dev/" of the terminal's
208 208 device path name in \fB/dev\fR. For example, \fBterm/a\fR or \fBpts/0\fR.
209 209 .RE
210 210
211 211 .sp
212 212 .ne 2
213 213 .na
214 214 \fB\fB-T\fR \fItaskidlist\fR\fR
215 215 .ad
216 216 .RS 17n
217 217 Matches only processes whose task \fBID\fR is in the given list. If \fBID\fR 0
218 218 is included in the list, this is interpreted as the task \fBID\fR of the
219 219 \fBpgrep\fR or \fBpkill\fR process.
220 220 .RE
221 221
222 222 .sp
223 223 .ne 2
224 224 .na
225 225 \fB\fB-u\fR \fIeuidlist\fR\fR
226 226 .ad
227 227 .RS 17n
228 228 Matches only processes whose effective user \fBID\fR is in the given list. Each
229 229 user \fBID\fR may be specified as either a login name or a numerical user
230 230 \fBID\fR.
231 231 .RE
232 232
233 233 .sp
234 234 .ne 2
235 235 .na
236 236 \fB\fB-U\fR \fIuidlist\fR\fR
237 237 .ad
238 238 .RS 17n
239 239 Matches only processes whose real user \fBID\fR is in the given list. Each user
240 240 \fBID\fR may be specified as either a login name or a numerical user \fBID\fR.
241 241 .RE
242 242
243 243 .sp
244 244 .ne 2
245 245 .na
246 246 \fB\fB-v\fR\fR
247 247 .ad
248 248 .RS 17n
↓ open down ↓ |
232 lines elided |
↑ open up ↑ |
249 249 Reverses the sense of the matching. Matches all processes \fBexcept\fR those
250 250 which meet the specified matching criteria.
251 251 .RE
252 252
253 253 .sp
254 254 .ne 2
255 255 .na
256 256 \fB\fB-x\fR\fR
257 257 .ad
258 258 .RS 17n
259 -Considers only processes whose argument string or executable file name
260 -\fBexactly\fR matches the specified \fIpattern\fR to be matching processes. The
261 -pattern match is considered to be exact when all characters in the process
262 -argument string or executable file name match the pattern.
259 +Considers only processes whose executable file name \fBexactly\fR matches the
260 +specified \fIpattern\fR. The pattern match is considered to be exact when all
261 +characters in the executable file name match the pattern.
263 262 .RE
264 263
265 264 .sp
266 265 .ne 2
267 266 .na
268 267 \fB\fB-z\fR \fIzoneidlist\fR\fR
269 268 .ad
270 269 .RS 17n
271 270 Matches only processes whose zone \fBID\fR is in the given list. Each zone
272 271 \fBID\fR may be specified as either a zone name or a numerical zone \fBID\fR.
273 272 This option is only useful when executed in the global zone. If the \fBpkill\fR
274 273 utility is used to send signals to processes in other zones, the process must
275 274 have asserted the \fB{PRIV_PROC_ZONE}\fR privilege (see \fBprivileges\fR(5)).
276 275 .RE
277 276
278 277 .sp
279 278 .ne 2
280 279 .na
281 280 \fB\fB-\fR\fIsignal\fR\fR
282 281 .ad
283 282 .RS 17n
284 283 Specifies the signal to send to each matched process. If no signal is
285 284 specified, \fBSIGTERM\fR is sent by default. The value of \fIsignal\fR can be
286 285 one of the symbolic names defined in \fBsignal.h\fR(3HEAD) without the
287 286 \fBSIG\fR prefix, or the corresponding signal number as a decimal value. The
288 287 \fB-\fR\fIsignal\fR option is only valid when specified as the first option to
289 288 \fBpkill\fR.
290 289 .RE
291 290
292 291 .SH OPERANDS
293 292 .sp
294 293 .LP
295 294 The following operand is supported:
296 295 .sp
297 296 .ne 2
298 297 .na
299 298 \fB\fIpattern\fR\fR
300 299 .ad
301 300 .RS 11n
302 301 Specifies an Extended Regular Expression (\fBERE\fR) pattern to match against
303 302 either the executable file name or full process argument string. See
304 303 \fBregex\fR(5) for a complete description of the \fBERE\fR syntax.
305 304 .RE
306 305
307 306 .SH EXAMPLES
308 307 .LP
309 308 \fBExample 1 \fRObtaining a Process ID
310 309 .sp
311 310 .LP
312 311 Obtain the process \fBID\fR of \fBsendmail\fR:
313 312
314 313 .sp
315 314 .in +2
316 315 .nf
317 316 example% \fBpgrep -x -u root sendmail\fR
318 317 283
319 318 .fi
320 319 .in -2
321 320 .sp
322 321
323 322 .LP
324 323 \fBExample 2 \fRTerminating a Process
325 324 .sp
326 325 .LP
327 326 Terminate the most recently created \fBxterm\fR:
328 327
329 328 .sp
330 329 .in +2
331 330 .nf
332 331 example% \fBpkill -n xterm\fR
333 332 .fi
334 333 .in -2
335 334 .sp
336 335
337 336 .SH EXIT STATUS
338 337 .sp
339 338 .LP
340 339 The following exit values are returned:
341 340 .sp
342 341 .ne 2
343 342 .na
344 343 \fB\fB0\fR\fR
345 344 .ad
346 345 .RS 5n
347 346 One or more processes were matched.
348 347 .RE
349 348
350 349 .sp
351 350 .ne 2
352 351 .na
353 352 \fB\fB1\fR\fR
354 353 .ad
355 354 .RS 5n
356 355 No processes were matched.
357 356 .RE
358 357
359 358 .sp
360 359 .ne 2
361 360 .na
362 361 \fB\fB2\fR\fR
363 362 .ad
364 363 .RS 5n
365 364 Invalid command line options were specified.
366 365 .RE
367 366
368 367 .sp
369 368 .ne 2
370 369 .na
371 370 \fB\fB3\fR\fR
372 371 .ad
373 372 .RS 5n
374 373 A fatal error occurred.
375 374 .RE
376 375
377 376 .SH FILES
378 377 .sp
379 378 .ne 2
380 379 .na
381 380 \fB\fB/proc/\fInnnnn\fR/psinfo\fR\fR
382 381 .ad
383 382 .RS 22n
384 383 Process information files
385 384 .RE
386 385
387 386 .SH SEE ALSO
388 387 .sp
389 388 .LP
390 389 \fBkill\fR(1), \fBproc\fR(1), \fBps\fR(1), \fBtruss\fR(1), \fBkill\fR(2),
391 390 \fBsignal.h\fR(3HEAD), \fBproc\fR(4), \fBattributes\fR(5), \fBprivileges\fR(5),
392 391 \fBregex\fR(5), \fBzones\fR(5)
393 392 .SH NOTES
394 393 .sp
395 394 .LP
396 395 Both utilities match the \fBERE\fR \fIpattern\fR argument against either the
397 396 \fBpr_fname\fR or \fBpr_psargs\fR fields of the
398 397 \fB/proc/\fR\fInnnnn\fR\fB/psinfo\fR files. The lengths of these strings are
399 398 limited according to definitions in \fB<sys/procfs.h>\fR\&. Patterns which can
400 399 match strings longer than the current limits may fail to match the intended set
401 400 of processes.
402 401 .sp
403 402 .LP
404 403 If the \fIpattern\fR argument contains \fBERE\fR meta-characters which are also
405 404 shell meta-characters, it may be necessary to enclose the pattern with
406 405 appropriate shell quotes.
407 406 .sp
408 407 .LP
409 408 Defunct processes are never matched by either \fBpgrep\fR or \fBpkill\fR.
410 409 .sp
411 410 .LP
412 411 The current \fBpgrep\fR or \fBpkill\fR process will never consider itself a
413 412 potential match.
↓ open down ↓ |
141 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX