1 .\" $NetBSD: kvm_getprocs.3,v 1.14 2004/02/10 12:48:48 jmmv 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
51 .Ft struct kinfo_proc *
52 .Fn kvm_getprocs "kvm_t *kd" "int op" "int arg" "int *cnt"
54 .Fn kvm_getargv "kvm_t *kd" "const struct kinfo_proc *p" "int nchr"
56 .Fn kvm_getenvv "kvm_t *kd" "const struct kinfo_proc *p" "int nchr"
57 .Ft struct kinfo_proc2 *
58 .Fn kvm_getproc2 "kvm_t *kd" "int op" "int arg" "int elemsize" "int *cnt"
60 .Fn kvm_getargv2 "kvm_t *kd" "const struct kinfo_proc2 *p" "int nchr"
62 .Fn kvm_getenvv2 "kvm_t *kd" "const struct kinfo_proc2 *p" "int nchr"
65 returns a (sub-)set of active processes in the kernel indicated by
71 arguments constitute a predicate
72 which limits the set of processes returned.
75 describes the filtering predicate as follows:
77 .Bl -tag -width 20n -offset indent -compact
81 processes with process id
84 processes with process group
86 .It Sy KERN_PROC_SESSION
87 processes with session id
90 processes with tty device
93 processes with effective user id
96 processes with real user id
99 processes with effective group id
101 .It Sy KERN_PROC_RGID
102 processes with real group id
106 The number of processes found is returned in the reference parameter
108 The processes are returned as a contiguous array of
111 This memory is locally allocated, and subsequent calls to
115 will overwrite this storage.
125 .Sy KERN_PROC_TTY_NODEV
126 to select processes with no controlling tty and
127 .Sy KERN_PROC_TTY_REVOKE
128 to select processes which have had their controlling tty
132 returns a null-terminated argument vector that corresponds to the
133 command line arguments passed to process indicated by
135 Most likely, these arguments correspond to the values passed to
138 This information is, however,
139 deliberately under control of the process itself.
140 Note that the original command name can be found, unaltered,
141 in the p_comm field of the process structure returned by
146 argument indicates the maximum number of characters, including null bytes,
147 to use in building the strings.
148 If this amount is exceeded, the string
149 causing the overflow is truncated and the partial result is returned.
150 This is handy for programs like
154 that print only a one line summary of a command and should not copy
155 out large amounts of text only to ignore it.
158 is zero, no limit is imposed and all argument strings are returned in
161 The memory allocated to the argv pointers and string storage
162 is owned by the kvm library.
167 calls will clobber this storage.
171 function is similar to
173 but returns the vector of environment strings.
174 This data is also alterable by the process.
179 but returns an array of
182 Additionally, only the first
184 bytes of each array entry are returned.
187 structure increases in size in a future release of
189 the kernel will only return the requested amount of data for
190 each array entry and programs that use
192 will continue to function without the need for recompilation.
198 are equivalents to the
204 structure to specify the process.
206 If called against an active kernel, the
211 functions will use the
213 interface and do not require access to the kernel memory device
232 .Xr kvm_openfiles 3 ,
236 These routines do not belong in the kvm interface.