BSD 4_4 development
[unix-history] / usr / share / man / cat3 / kvm_getargv.0
KVM_GETPROCS(3) BSD Programmer's Manual KVM_GETPROCS(3)
N\bNA\bAM\bME\bE
k\bkv\bvm\bm_\b_g\bge\bet\btp\bpr\bro\boc\bcs\bs, k\bkv\bvm\bm_\b_g\bge\bet\bta\bar\brg\bgv\bv, k\bkv\bvm\bm_\b_g\bge\bet\bte\ben\bnv\bvv\bv - access user process state
S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
#\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<k\bkv\bvm\bm.\b.h\bh>\b>
#\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/k\bki\bin\bnf\bfo\bo.\b.h\bh>\b>
#\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<s\bsy\bys\bs/\b/k\bki\bin\bnf\bfo\bo_\b_p\bpr\bro\boc\bc.\b.h\bh>\b>
_\bs_\bt_\br_\bu_\bc_\bt _\bk_\bi_\bn_\bf_\bo_\b__\bp_\br_\bo_\bc _\b*
k\bkv\bvm\bm_\b_g\bge\bet\btp\bpr\bro\boc\bcs\bs(_\bk_\bv_\bm_\b__\bt _\b*_\bk_\bd, _\bi_\bn_\bt _\bo_\bp, _\bi_\bn_\bt _\ba_\br_\bg, _\bi_\bn_\bt _\b*_\bc_\bn_\bt);
_\bc_\bh_\ba_\br _\b*_\b*
k\bkv\bvm\bm_\b_g\bge\bet\bta\bar\brg\bgv\bv(_\bk_\bv_\bm_\b__\bt _\b*_\bk_\bd, _\bc_\bo_\bn_\bs_\bt _\bs_\bt_\br_\bu_\bc_\bt _\bk_\bi_\bn_\bf_\bo_\b__\bp_\br_\bo_\bc _\b*_\bp, _\bi_\bn_\bt _\bn_\bc_\bh_\br);
_\bc_\bh_\ba_\br _\b*_\b*
k\bkv\bvm\bm_\b_g\bge\bet\bte\ben\bnv\bvv\bv(_\bk_\bv_\bm_\b__\bt _\b*_\bk_\bd, _\bc_\bo_\bn_\bs_\bt _\bs_\bt_\br_\bu_\bc_\bt _\bk_\bi_\bn_\bf_\bo_\b__\bp_\br_\bo_\bc _\b*_\bp, _\bi_\bn_\bt _\bn_\bc_\bh_\br);
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
k\bkv\bvm\bm_\b_g\bge\bet\btp\bpr\bro\boc\bcs\bs() returns a (sub-)set of active processes in the kernel in-
dicated by _\bk_\bd_\b. The _\bo_\bp and _\ba_\br_\bg arguments constitute a predicate which lim-
its the set of processes returned. The value of _\bo_\bp describes the filter-
ing predicate as follows:
K\bKI\bIN\bNF\bFO\bO_\b_P\bPR\bRO\bOC\bC_\b_A\bAL\bLL\bL all processes
K\bKI\bIN\bNF\bFO\bO_\b_P\bPR\bRO\bOC\bC_\b_P\bPI\bID\bD processes with process id _\ba_\br_\bg
K\bKI\bIN\bNF\bFO\bO_\b_P\bPR\bRO\bOC\bC_\b_P\bPG\bGR\bRP\bP processes with process group _\ba_\br_\bg
K\bKI\bIN\bNF\bFO\bO_\b_P\bPR\bRO\bOC\bC_\b_S\bSE\bES\bSS\bSI\bIO\bON\bN processes with session _\ba_\br_\bg
K\bKI\bIN\bNF\bFO\bO_\b_P\bPR\bRO\bOC\bC_\b_T\bTT\bTY\bY processes with tty _\ba_\br_\bg
K\bKI\bIN\bNF\bFO\bO_\b_P\bPR\bRO\bOC\bC_\b_U\bUI\bID\bD processes with effective user id _\ba_\br_\bg
K\bKI\bIN\bNF\bFO\bO_\b_P\bPR\bRO\bOC\bC_\b_R\bRU\bUI\bID\bD processes with real user id _\ba_\br_\bg
The number of processes found is returned in the reference parameter _\bc_\bn_\bt.
The processes are returned as a contiguous array of kinfo_proc struc-
tures. This memory is locally allocated, and subsequent calls to
k\bkv\bvm\bm_\b_g\bge\bet\btp\bpr\bro\boc\bcs\bs() and k\bkv\bvm\bm_\b_c\bcl\blo\bos\bse\be() will overwrite this storage.
k\bkv\bvm\bm_\b_g\bge\bet\bta\bar\brg\bgv\bv() returns a null-terminated argument vector that corresponds
to the command line arguments passed to process indicated by _\bp. Most
likely, these arguments correspond to the values passed to exec(3) on
process creation. This information is, however, deliberately under con-
trol of the process itself. Note that the original command name can be
found, unaltered, in the p_comm field of the process structure returned
by k\bkv\bvm\bm_\b_g\bge\bet\btp\bpr\bro\boc\bcs\bs().
The _\bn_\bc_\bh_\br argument indicates the maximum number of characters, including
null bytes, to use in building the strings. If this amount is exceeded,
the string causing the overflow is truncated and the partial result is
returned. This is handy for programs like ps(1) and w(1) that print only
a one line summary of a command and should not copy out large amounts of
text only to ignore it. If _\bn_\bc_\bh_\br is zero, no limit is imposed and all ar-
gument strings are returned in their entirety.
The memory allocated to the argv pointers and string storage is owned by
the kvm library. Subsequent k\bkv\bvm\bm_\b_g\bge\bet\btp\bpr\bro\boc\bcs\bs() and kvm_close(3) calls will
clobber this storage.
The k\bkv\bvm\bm_\b_g\bge\bet\bte\ben\bnv\bvv\bv() function is similar to k\bkv\bvm\bm_\b_g\bge\bet\bta\bar\brg\bgv\bv() but returns the
vector of environment strings. This data is also alterable by the pro-
cess.
R\bRE\bET\bTU\bUR\bRN\bN V\bVA\bAL\bLU\bUE\bES\bS
k\bkv\bvm\bm_\b_g\bge\bet\btp\bpr\bro\boc\bcs\bs(), k\bkv\bvm\bm_\b_g\bge\bet\bta\bar\brg\bgv\bv(), and k\bkv\bvm\bm_\b_g\bge\bet\bte\ben\bnv\bvv\bv(), all return NULL on
failure.
B\bBU\bUG\bGS\bS
These routines do not belong in the kvm interface.
S\bSE\bEE\bE A\bAL\bLS\bSO\bO
kvm(3), kvm_close(3), kvm_geterr(3), kvm_nlist(3), kvm_open(3),
kvm_openfiles(3), kvm_read(3), kvm_write(3)
4.4BSD June 4, 1993 2