1kvm_getu(3KVM)            Kernel VM Library Functions           kvm_getu(3KVM)
2
3
4

NAME

6       kvm_getu,  kvm_getcmd  -  get  the u-area or invocation arguments for a
7       process
8

SYNOPSIS

10       cc [ flag... ] file... -lkvm [ library...]
11       #include <kvm.h>
12       #include <sys/param.h>
13       #include <sys/user.h>
14       #include <sys/proc.h>
15
16       struct user *kvm_getu(kvm_t *kd, struct proc *proc);
17
18
19       int kvm_getcmd(kvm_t *kd, struct proc *proc, struct user *u, char ***arg,
20            char ***env);
21
22

DESCRIPTION

24       The kvm_getu() function reads the u-area of the  process  specified  by
25       proc  to  an  area  of  static storage associated with kd and returns a
26       pointer to it. Subsequent  calls  to  kvm_getu()  will  overwrite  this
27       static area.
28
29
30       The  kd  argument  is  a  pointer  to  a  kernel descriptor returned by
31       kvm_open(3KVM). The proc argument is a pointer to a copy in the current
32       process's address space of a proc structure, obtained, for instance, by
33       a prior kvm_nextproc(3KVM) call.
34
35
36       The kvm_getcmd() function constructs a list  of  string  pointers  that
37       represent  the command arguments and environment that were used to ini‐
38       tiate the process specified by proc.
39
40
41       The kd argument is  a  pointer  to  a  kernel  descriptor  returned  by
42       kvm_open(3KVM).  The  u  argument is a pointer to a copy in the current
43       process's address space of a user structure, obtained, for instance, by
44       a prior kvm_getu() call. If arg is not NULL, the command line arguments
45       are formed into a null-terminated array of string pointers. The address
46       of  the  first such pointer is returned in arg. If env is not NULL, the
47       environment is formed into a null-terminated array of string  pointers.
48       The address of the first of these is returned in env.
49
50
51       The  pointers  returned  in arg and env refer to data allocated by mal‐
52       loc() and should be freed by a call to free() when  no  longer  needed.
53       See malloc(3C). Both the string pointers and the strings themselves are
54       deallocated when freed.
55
56
57       Since the environment and command line arguments might have been  modi‐
58       fied  by the user process, there is no guarantee that it will be possi‐
59       ble to reconstruct the original command at all.  The kvm_getcmd() func‐
60       tion  will  make  the  best  attempt possible, returning −1 if the user
61       process data is unrecognizable.
62

RETURN VALUES

64       On success, kvm_getu() returns a pointer to a copy of the u-area of the
65       process specified by proc. On failure, it returns NULL.
66
67
68       The kvm_getcmd() function returns 0 on success and −1 on failure. If −1
69       is returned, the caller still has the option of using the command  line
70       fragment that is stored in the u-area.
71

ATTRIBUTES

73       See attributes(5) for descriptions of the following attributes:
74
75
76
77
78       ┌─────────────────────────────┬─────────────────────────────┐
79       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
80       ├─────────────────────────────┼─────────────────────────────┤
81       │Interface Stability          │Stable                       │
82       ├─────────────────────────────┼─────────────────────────────┤
83       │MT-Level                     │Unsafe                       │
84       └─────────────────────────────┴─────────────────────────────┘
85

SEE ALSO

87       kvm_nextproc(3KVM),    kvm_open(3KVM),   kvm_kread(3KVM),   malloc(3C),
88       libkvm(3LIB), attributes(5)
89

NOTES

91       On systems that support both 32-bit and 64-bit  processes,  the  64-bit
92       implementation  of  libkvm  ensures that the arg and env pointer arrays
93       for kvm_getcmd() are translated to the same form as if they were 64-bit
94       processes.   Applications  that  wish  to  access  the raw 32-bit stack
95       directly can use kvm_uread(). See kvm_read(3KVM).
96
97
98
99SunOS 5.11                        2 May 2002                    kvm_getu(3KVM)
Impressum