1 .\" $NetBSD: kvm_getprocs.3,v 1.13 2003/08/07 16:44:37 agc Exp $
3 .\" Copyright (c) 1992, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" This code is derived from software developed by the Computer Systems
7 .\" Engineering group at Lawrence Berkeley Laboratory under DARPA contract
8 .\" BG 91-66 and contributed to Berkeley.
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
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 .\" 3. Neither the name of the University nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" @(#)kvm_getprocs.3 8.1 (Berkeley) 6/4/93
43 .Nd access user process state
52 .Ft struct kinfo_proc *
53 .Fn kvm_getprocs "kvm_t *kd" "int op" "int arg" "int *cnt"
55 .Fn kvm_getargv "kvm_t *kd" "const struct kinfo_proc *p" "int nchr"
57 .Fn kvm_getenvv "kvm_t *kd" "const struct kinfo_proc *p" "int nchr"
58 .Ft struct kinfo_proc2 *
59 .Fn kvm_getproc2 "kvm_t *kd" "int op" "int arg" "int elemsize" "int *cnt"
61 .Fn kvm_getargv2 "kvm_t *kd" "const struct kinfo_proc2 *p" "int nchr"
63 .Fn kvm_getenvv2 "kvm_t *kd" "const struct kinfo_proc2 *p" "int nchr"
66 returns a (sub-)set of active processes in the kernel indicated by
72 arguments constitute a predicate
73 which limits the set of processes returned.
76 describes the filtering predicate as follows:
78 .Bl -tag -width 20n -offset indent -compact
82 processes with process id
85 processes with process group
87 .It Sy KERN_PROC_SESSION
88 processes with session id
91 processes with tty device
94 processes with effective user id
97 processes with real user id
100 processes with effective group id
102 .It Sy KERN_PROC_RGID
103 processes with real group id
107 The number of processes found is returned in the reference parameter
109 The processes are returned as a contiguous array of
112 This memory is locally allocated, and subsequent calls to
116 will overwrite this storage.
126 .Sy KERN_PROC_TTY_NODEV
127 to select processes with no controlling tty and
128 .Sy KERN_PROC_TTY_REVOKE
129 to select processes which have had their controlling tty
133 returns a null-terminated argument vector that corresponds to the
134 command line arguments passed to process indicated by
136 Most likely, these arguments correspond to the values passed to
139 This information is, however,
140 deliberately under control of the process itself.
141 Note that the original command name can be found, unaltered,
142 in the p_comm field of the process structure returned by
147 argument indicates the maximum number of characters, including null bytes,
148 to use in building the strings.
149 If this amount is exceeded, the string
150 causing the overflow is truncated and the partial result is returned.
151 This is handy for programs like
155 that print only a one line summary of a command and should not copy
156 out large amounts of text only to ignore it.
159 is zero, no limit is imposed and all argument strings are returned in
162 The memory allocated to the argv pointers and string storage
163 is owned by the kvm library.
168 calls will clobber this storage.
172 function is similar to
174 but returns the vector of environment strings.
175 This data is also alterable by the process.
180 but returns an array of
183 Additionally, only the first
185 bytes of each array entry are returned.
188 structure increases in size in a future release of
190 the kernel will only return the requested amount of data for
191 each array entry and programs that use
193 will continue to function without the need for recompilation.
199 are equivalents to the
205 structure to specify the process.
207 If called against an active kernel, the
212 functions will use the
214 interface and do not require access to the kernel memory device
233 .Xr kvm_openfiles 3 ,
237 These routines do not belong in the kvm interface.