NAME
kkvvmmggeettpprrooccss, kkvvmmggeettaarrggvv, kkvvmmggeetteennvvvv - access user process state
SYNOPSIS
##iinncclluuddee <
> ##iinncclluuddee <
struct kinfoproc * kkvvmmggeettpprrooccss(kvmt *kd, int op, int arg, int *cnt); char ** kkvvmmggeettaarrggvv(kvmt *kd, const struct kinfoproc *p, int nchr); char ** kkvvmmggeetteennvvvv(kvmt *kd, const struct kinfoproc *p, int nchr);> DESCRIPTION
kkvvmmggeettpprrooccss() returns a (sub-)set of active processes in the kernel
indicated by kd. The op and arg arguments constitute a predicate whichlimits the set of processes returned. The value of op describes the fil-
tering predicate as follows: KKEERRNNPPRROOCCAALLLL all processes KKEERRNNPPRROOCCPPIIDD processes with process id arg KKEERRNNPPRROOCCPPGGRRPP processes with process group arg KKEERRNNPPRROOCCSSEESSSSIIOONN processes with session arg KKEERRNNPPRROOCCTTTTYY processes with tty arg KKEERRNNPPRROOCCUUIIDD processes with effective user id arg KKEERRNNPPRROOCCRRUUIIDD processes with real user id arg The number of processes found is returned in the reference parameter cnt.The processes are returned as a contiguous array of kinfoproc struc-
tures. This memory is locally allocated, and subsequent calls to kkvvmmggeettpprrooccss() and kkvvmmcclloossee() will overwrite this storage.kkvvmmggeettaarrggvv() returns a null-terminated argument vector that corresponds
to the command line arguments passed to process indicated by p. Most likely, these arguments correspond to the values passed to exec(3) onprocess 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 pcomm field of the process structure returned by kkvvmmggeettpprrooccss(). The nchr 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 nchr is zero, no limit is imposed and all argument strings are returned in their entirety. The memory allocated to the argv pointers and string storage is owned by the kvm library. Subsequent kkvvmmggeettpprrooccss() and kvmclose(3) calls will clobber this storage. The kkvvmmggeetteennvvvv() function is similar to kkvvmmggeettaarrggvv() but returns the vector of environment strings. This data is also alterable by the process.RETURN VALUES
kkvvmmggeettpprrooccss(), kkvvmmggeettaarrggvv(), and kkvvmmggeetteennvvvv(), all return NULL on failure.BUGS
These routines do not belong in the kvm interface.SEE ALSO
kvm(3), kvmclose(3), kvmgeterr(3), kvmnlist(3), kvmopen(3), kvmopenfiles(3), kvmread(3), kvmwrite(3) BSD June 4, 1993 BSD