2004-03-25 19:08:48 +00:00
|
|
|
.\" $NetBSD: pkill.1,v 1.8 2003/02/14 15:59:18 grant Exp $
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
|
|
|
.\" 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.
|
|
|
|
.\"
|
2013-08-09 08:38:51 +00:00
|
|
|
.Dd August 9, 2013
|
2004-03-25 19:08:48 +00:00
|
|
|
.Dt PKILL 1
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
2004-05-19 10:46:56 +00:00
|
|
|
.Nm pgrep , pkill
|
2004-03-25 19:08:48 +00:00
|
|
|
.Nd find or signal processes by name
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Nm pgrep
|
2010-02-12 18:52:24 +00:00
|
|
|
.Op Fl LSafilnoqvx
|
2005-03-20 11:03:11 +00:00
|
|
|
.Op Fl F Ar pidfile
|
2004-03-25 19:08:48 +00:00
|
|
|
.Op Fl G Ar gid
|
2004-03-25 23:19:16 +00:00
|
|
|
.Op Fl M Ar core
|
|
|
|
.Op Fl N Ar system
|
2004-03-25 19:08:48 +00:00
|
|
|
.Op Fl P Ar ppid
|
|
|
|
.Op Fl U Ar uid
|
2013-08-09 08:38:51 +00:00
|
|
|
.Op Fl c Ar class
|
2004-03-25 19:08:48 +00:00
|
|
|
.Op Fl d Ar delim
|
|
|
|
.Op Fl g Ar pgrp
|
2005-03-20 10:53:54 +00:00
|
|
|
.Op Fl j Ar jid
|
2004-03-25 19:08:48 +00:00
|
|
|
.Op Fl s Ar sid
|
|
|
|
.Op Fl t Ar tty
|
|
|
|
.Op Fl u Ar euid
|
2004-05-19 10:46:56 +00:00
|
|
|
.Ar pattern ...
|
2004-03-25 19:08:48 +00:00
|
|
|
.Nm pkill
|
2004-05-19 10:46:56 +00:00
|
|
|
.Op Fl Ar signal
|
2010-07-12 01:58:46 +00:00
|
|
|
.Op Fl ILafilnovx
|
2005-03-20 11:03:11 +00:00
|
|
|
.Op Fl F Ar pidfile
|
2004-03-25 19:08:48 +00:00
|
|
|
.Op Fl G Ar gid
|
2004-03-25 23:19:16 +00:00
|
|
|
.Op Fl M Ar core
|
|
|
|
.Op Fl N Ar system
|
2004-03-25 19:08:48 +00:00
|
|
|
.Op Fl P Ar ppid
|
|
|
|
.Op Fl U Ar uid
|
2013-08-09 08:38:51 +00:00
|
|
|
.Op Fl c Ar class
|
2004-03-25 19:08:48 +00:00
|
|
|
.Op Fl g Ar pgrp
|
2005-03-20 10:53:54 +00:00
|
|
|
.Op Fl j Ar jid
|
2004-03-25 19:08:48 +00:00
|
|
|
.Op Fl s Ar sid
|
|
|
|
.Op Fl t Ar tty
|
|
|
|
.Op Fl u Ar euid
|
2004-05-19 10:46:56 +00:00
|
|
|
.Ar pattern ...
|
2004-03-25 19:08:48 +00:00
|
|
|
.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:
|
2005-03-20 11:03:11 +00:00
|
|
|
.Bl -tag -width ".Fl F Ar pidfile"
|
|
|
|
.It Fl F Ar pidfile
|
2005-06-14 11:50:53 +00:00
|
|
|
Restrict matches to a process whose PID is stored in the
|
2005-03-20 11:03:11 +00:00
|
|
|
.Ar pidfile
|
|
|
|
file.
|
2005-08-25 20:10:47 +00:00
|
|
|
.It Fl G Ar gid
|
|
|
|
Restrict matches to processes with a real group ID in the comma-separated
|
|
|
|
list
|
|
|
|
.Ar gid .
|
2005-11-16 10:36:44 +00:00
|
|
|
.It Fl I
|
2006-12-20 11:57:22 +00:00
|
|
|
Request confirmation before attempting to signal each process.
|
2005-08-25 20:10:47 +00:00
|
|
|
.It Fl L
|
2005-08-24 19:38:28 +00:00
|
|
|
The
|
|
|
|
.Ar pidfile
|
2005-08-25 20:10:47 +00:00
|
|
|
file given for the
|
|
|
|
.Fl F
|
|
|
|
option must be locked with the
|
2005-08-24 19:38:28 +00:00
|
|
|
.Xr flock 2
|
|
|
|
syscall or created with
|
|
|
|
.Xr pidfile 3 .
|
2004-07-18 23:05:31 +00:00
|
|
|
.It Fl M Ar core
|
2004-03-25 23:19:16 +00:00
|
|
|
Extract values associated with the name list from the specified core
|
2004-03-26 08:47:01 +00:00
|
|
|
instead of the currently running system.
|
2004-07-18 23:05:31 +00:00
|
|
|
.It Fl N Ar system
|
2004-03-26 08:54:27 +00:00
|
|
|
Extract the name list from the specified system instead of the default,
|
|
|
|
which is the kernel image the system has booted from.
|
2005-03-20 11:17:06 +00:00
|
|
|
.It Fl P Ar ppid
|
|
|
|
Restrict matches to processes with a parent process ID in the
|
|
|
|
comma-separated list
|
|
|
|
.Ar ppid .
|
2005-03-20 11:30:26 +00:00
|
|
|
.It Fl S
|
|
|
|
Search also in system processes (kernel threads).
|
2004-03-25 19:08:48 +00:00
|
|
|
.It Fl U Ar uid
|
|
|
|
Restrict matches to processes with a real user ID in the comma-separated
|
|
|
|
list
|
|
|
|
.Ar uid .
|
|
|
|
.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.
|
2009-05-17 04:34:14 +00:00
|
|
|
.It Fl a
|
|
|
|
Include process ancestors in the match list.
|
|
|
|
By default, the current
|
|
|
|
.Nm pgrep
|
|
|
|
or
|
|
|
|
.Nm pkill
|
|
|
|
process and all of its ancestors are excluded (unless
|
|
|
|
.Fl v
|
|
|
|
is used).
|
2013-08-09 08:38:51 +00:00
|
|
|
.It Fl c Ar class
|
|
|
|
Restrict matches to processes running with specified login class
|
|
|
|
.Ar class .
|
2004-03-25 19:08:48 +00:00
|
|
|
.It Fl f
|
|
|
|
Match against full argument lists.
|
|
|
|
The default is to match against process names.
|
|
|
|
.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.
|
2005-03-20 11:12:13 +00:00
|
|
|
.It Fl i
|
|
|
|
Ignore case distinctions in both the process table and the supplied pattern.
|
2005-03-20 10:53:54 +00:00
|
|
|
.It Fl j Ar jid
|
|
|
|
Restrict matches to processes inside jails with a jail ID in the comma-separated
|
|
|
|
list
|
|
|
|
.Ar jid .
|
Fix and extend the -j option to pkill/pgrep WRT the jail
wildcard specifications. Earlier the only wildcard syntax
was "-j 0" for "any jail". There were at least
two shortcomings in it: First, jail ID 0 was abused; it
meant "no jail" in other utils, e.g., ps(1). Second, it
was impossible to match processed not in jail, which could
be useful to rc.d developers. Therefore a new syntax is
introduced: "-j any" means any jail while "-j none" means
out of jail. The old syntax is preserved for compatibility,
but now it's deprecated because it's limited and confusing.
Update the respective regression tests. While I'm here,
make the tests more complex but sensitive: Start several
processes, some in jail and some out of jail, so we can
detect that only the right processes are killed by pkill
or matched by pgrep.
Reviewed by: gad, pjd
MFC after: 1 week
2006-11-23 11:55:17 +00:00
|
|
|
The value
|
|
|
|
.Dq Li any
|
|
|
|
matches processes in any jail.
|
|
|
|
The value
|
|
|
|
.Dq Li none
|
|
|
|
matches processes not in jail.
|
2004-03-25 19:08:48 +00:00
|
|
|
.It Fl l
|
|
|
|
Long output.
|
2010-06-20 08:48:30 +00:00
|
|
|
For
|
|
|
|
.Nm pgrep ,
|
|
|
|
print the process name in addition to the process ID for each matching
|
2004-03-25 19:08:48 +00:00
|
|
|
process.
|
|
|
|
If used in conjunction with
|
|
|
|
.Fl f ,
|
|
|
|
print the process ID and the full argument list for each matching process.
|
2010-06-20 08:48:30 +00:00
|
|
|
For
|
|
|
|
.Nm pkill ,
|
|
|
|
display the kill command used for each process killed.
|
2005-03-20 11:47:44 +00:00
|
|
|
.It Fl n
|
2005-03-20 11:42:26 +00:00
|
|
|
Select only the newest (most recently started) of the matching processes.
|
|
|
|
.It Fl o
|
|
|
|
Select only the oldest (least recently started) of the matching processes.
|
2010-02-12 18:52:24 +00:00
|
|
|
.It Fl q
|
|
|
|
Do not write anything to standard output.
|
2004-03-25 19:08:48 +00:00
|
|
|
.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 tty
|
|
|
|
Restrict matches to processes associated with a terminal in the
|
|
|
|
comma-separated list
|
|
|
|
.Ar tty .
|
2008-09-30 17:30:39 +00:00
|
|
|
Terminal names may be of the form
|
|
|
|
.Pa tty Ns Ar xx
|
|
|
|
or the shortened form
|
|
|
|
.Ar xx .
|
2004-05-19 10:46:56 +00:00
|
|
|
A single dash
|
|
|
|
.Pq Ql -
|
|
|
|
matches processes not associated with a terminal.
|
2004-03-25 19:08:48 +00:00
|
|
|
.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 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.
|
2004-05-19 10:46:56 +00:00
|
|
|
.It Fl Ns Ar signal
|
2004-03-25 19:08:48 +00:00
|
|
|
A non-negative decimal number or symbolic signal name specifying the signal
|
2004-05-19 10:46:56 +00:00
|
|
|
to be sent instead of the default
|
|
|
|
.Dv TERM .
|
2004-03-25 19:08:48 +00:00
|
|
|
This option is valid only when given as the first argument to
|
|
|
|
.Nm pkill .
|
|
|
|
.El
|
|
|
|
.Pp
|
2004-08-16 04:49:43 +00:00
|
|
|
If any
|
|
|
|
.Ar pattern
|
|
|
|
operands are specified, they are used as regular expressions to match
|
|
|
|
the command name or full argument list of each process.
|
|
|
|
If the
|
|
|
|
.Fl f
|
|
|
|
option is not specified, then the
|
|
|
|
.Ar pattern
|
|
|
|
will attempt to match the command name.
|
|
|
|
However, presently
|
|
|
|
.Fx
|
|
|
|
will only keep track of the first 19 characters of the command
|
|
|
|
name for each process.
|
|
|
|
Attempts to match any characters after the first 19 of a command name
|
|
|
|
will quietly fail.
|
|
|
|
.Pp
|
2004-03-25 19:08:48 +00:00
|
|
|
Note that a running
|
|
|
|
.Nm pgrep
|
|
|
|
or
|
|
|
|
.Nm pkill
|
|
|
|
process will never consider itself nor system processes (kernel threads) as
|
|
|
|
a potential match.
|
|
|
|
.Sh EXIT STATUS
|
2004-05-19 10:46:56 +00:00
|
|
|
The
|
2004-03-25 19:08:48 +00:00
|
|
|
.Nm pgrep
|
|
|
|
and
|
|
|
|
.Nm pkill
|
2004-05-19 10:46:56 +00:00
|
|
|
utilities
|
2004-03-25 19:08:48 +00:00
|
|
|
return one of the following values upon exit:
|
2004-05-19 10:46:56 +00:00
|
|
|
.Bl -tag -width indent
|
2004-03-25 19:08:48 +00:00
|
|
|
.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
|
Fix and extend the -j option to pkill/pgrep WRT the jail
wildcard specifications. Earlier the only wildcard syntax
was "-j 0" for "any jail". There were at least
two shortcomings in it: First, jail ID 0 was abused; it
meant "no jail" in other utils, e.g., ps(1). Second, it
was impossible to match processed not in jail, which could
be useful to rc.d developers. Therefore a new syntax is
introduced: "-j any" means any jail while "-j none" means
out of jail. The old syntax is preserved for compatibility,
but now it's deprecated because it's limited and confusing.
Update the respective regression tests. While I'm here,
make the tests more complex but sensitive: Start several
processes, some in jail and some out of jail, so we can
detect that only the right processes are killed by pkill
or matched by pgrep.
Reviewed by: gad, pjd
MFC after: 1 week
2006-11-23 11:55:17 +00:00
|
|
|
.Sh COMPATIBILITY
|
|
|
|
Historically the option
|
|
|
|
.Dq Fl j Li 0
|
|
|
|
means any jail, although in other utilities such as
|
|
|
|
.Xr ps 1
|
|
|
|
jail ID
|
|
|
|
.Li 0
|
|
|
|
has the opposite meaning, not in jail.
|
|
|
|
Therefore
|
|
|
|
.Dq Fl j Li 0
|
|
|
|
is deprecated, and its use is discouraged in favor of
|
|
|
|
.Dq Fl j Li any .
|
2004-03-25 19:08:48 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr kill 1 ,
|
2004-03-25 23:32:12 +00:00
|
|
|
.Xr killall 1 ,
|
2004-03-25 19:08:48 +00:00
|
|
|
.Xr ps 1 ,
|
2005-08-24 19:38:28 +00:00
|
|
|
.Xr flock 2 ,
|
2004-03-25 19:08:48 +00:00
|
|
|
.Xr kill 2 ,
|
|
|
|
.Xr sigaction 2 ,
|
2005-08-24 19:38:28 +00:00
|
|
|
.Xr pidfile 3 ,
|
2004-05-19 10:46:56 +00:00
|
|
|
.Xr re_format 7
|
|
|
|
.\" Xr signal 7
|
2004-03-25 19:08:48 +00:00
|
|
|
.Sh HISTORY
|
2004-05-19 10:46:56 +00:00
|
|
|
The
|
2004-03-25 19:08:48 +00:00
|
|
|
.Nm pkill
|
|
|
|
and
|
|
|
|
.Nm pgrep
|
2004-05-19 10:46:56 +00:00
|
|
|
utilities
|
2004-03-25 19:08:48 +00:00
|
|
|
first appeared in
|
|
|
|
.Nx 1.6 .
|
|
|
|
They are modelled after utilities of the same name that appeared in Sun
|
|
|
|
Solaris 7.
|
2004-03-25 23:32:12 +00:00
|
|
|
They made their first appearance in
|
|
|
|
.Fx 5.3 .
|
2004-03-25 19:08:48 +00:00
|
|
|
.Sh AUTHORS
|
|
|
|
.An Andrew Doran
|
2004-05-19 10:46:56 +00:00
|
|
|
.Aq ad@NetBSD.org
|