Kernel VM Library Functions kvmgetu(3KVM)
NAME
kvmgetu, kvmgetcmd - get the u-area or invocation argu-
ments for a process
SYNOPSIS
cc [ flag... ] file... -lkvm [ library...]
#include
#include
#include
#include
struct user *kvmgetu(kvmt *kd, struct proc *proc);
int kvmgetcmd(kvmt *kd, struct proc *proc, struct user *u, char ***arg,
char ***env);
DESCRIPTION
The kvmgetu() function reads the u-area of the process
specified by proc to an area of static storage associated
with kd and returns a pointer to it. Subsequent calls to
kvmgetu() will overwrite this static area.
The kd argument is a pointer to a kernel descriptor returned
by kvmopen(3KVM). The proc argument is a pointer to a copy
in the current process's address space of a proc structure,
obtained, for instance, by a prior kvmnextproc(3KVM) call.
The kvmgetcmd() function constructs a list of string
pointers that represent the command arguments and environ-
ment that were used to initiate the process specified by
proc.
The kd argument is a pointer to a kernel descriptor returned
by kvmopen(3KVM). The u argument is a pointer to a copy in
the current process's address space of a user structure,
obtained, for instance, by a prior kvmgetu() call. If arg
is not NUL, the command line arguments are formed into a
null-terminated array of string pointers. The address of the
first such pointer is returned in arg. If env is not NUL,
the environment is formed into a null-terminated array of
string pointers. The address of the first of these is
returned in env.
The pointers returned in arg and env refer to data allocated
by malloc() and should be freed by a call to free() when no
longer needed. See malloc(3C). Both the string pointers and
SunOS 5.11 Last change: 2 May 2002 1
Kernel VM Library Functions kvmgetu(3KVM)
the strings themselves are deallocated when freed.
Since the environment and command line arguments might have
been modified by the user process, there is no guarantee
that it will be possible to reconstruct the original command
at all. The kvmgetcmd() function will make the best
attempt possible, returning -1 if the user process data is
unrecognizable.
RETURN VALUES
On success, kvmgetu() returns a pointer to a copy of the
u-area of the process specified by proc. On failure, it
returns NUL.
The kvmgetcmd() function returns 0 on success and -1 on
failure. If -1 is returned, the caller still has the option
of using the command line fragment that is stored in the u-
area.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Stable
MT-Level Unsafe
SEE ALSO
kvmnextproc(3KVM), kvmopen(3KVM), kvmkread(3KVM),
malloc(3C), libkvm(3LIB), attributes(5)
NOTES
On systems that support both 32-bit and 64-bit processes,
the 64-bit implementation of libkvm ensures that the arg and
env pointer arrays for kvmgetcmd() are translated to the
same form as if they were 64-bit processes. Applications
that wish to access the raw 32-bit stack directly can use
kvmuread(). See kvmread(3KVM).
SunOS 5.11 Last change: 2 May 2002 2
|