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