version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
PUTENV |
|
|
2 |
!!!PUTENV |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
ERRORS |
|
|
8 |
NOTES |
|
|
9 |
CONFORMING TO |
|
|
10 |
SEE ALSO |
|
|
11 |
---- |
|
|
12 |
!!NAME |
|
|
13 |
|
|
|
14 |
|
|
|
15 |
putenv - change or add an environment variable |
|
|
16 |
!!SYNOPSIS |
|
|
17 |
|
|
|
18 |
|
|
|
19 |
__#include |
|
|
20 |
__''string''__); |
|
|
21 |
__ |
|
|
22 |
!!DESCRIPTION |
|
|
23 |
|
|
|
24 |
|
|
|
25 |
The __putenv()__ function adds or changes the value of |
|
|
26 |
environment variables. The argument ''string'' is of the |
|
|
27 |
form ''name''=''value''. If ''name'' does not |
|
|
28 |
already exist in the environment, then ''string'' is |
|
|
29 |
added to the environment. If ''name'' does exist, then |
|
|
30 |
the value of ''name'' in the environment is changed to |
|
|
31 |
''value''. The string pointed to by ''string'' becomes |
|
|
32 |
part of the environment, so altering the string changes the |
|
|
33 |
environment. |
|
|
34 |
!!RETURN VALUE |
|
|
35 |
|
|
|
36 |
|
|
|
37 |
The __putenv()__ function returns zero on success, or -1 |
|
|
38 |
if an error occurs. |
|
|
39 |
!!ERRORS |
|
|
40 |
|
|
|
41 |
|
|
|
42 |
__ENOMEM__ |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
Insufficient space to allocate new environment. |
|
|
46 |
!!NOTES |
|
|
47 |
|
|
|
48 |
|
|
|
49 |
The __putenv()__ function is not required to be |
|
|
50 |
reentrant, and the one in libc4, libc5 and glibc2.0 is not, |
|
|
51 |
but the glibc2.1 version is. |
|
|
52 |
|
|
|
53 |
|
|
|
54 |
Description for libc4, libc5, glibc: If the argument |
|
|
55 |
''string'' is of the form ''name'', and does not |
|
|
56 |
contain an `=' character, then the variable ''name'' is |
|
|
57 |
removed from the environment. If __putenv()__ has to |
|
|
58 |
allocate a new array ''environ'', and the previous array |
|
|
59 |
was also allocated by __putenv()__, then it will be |
|
|
60 |
freed. In no case will the old storage associated to the |
|
|
61 |
environment variable itself be freed. |
|
|
62 |
|
|
|
63 |
|
|
|
64 |
The libc4 and libc5 and glibc 2.1.2 versions conform to |
|
|
65 |
SUSv2: the pointer ''string'' given to __putenv()__ is |
|
|
66 |
used. In particular, this string becomes part of the |
|
|
67 |
environment; changing it later will change the environment. |
|
|
68 |
(Thus, it is an error is to call __putenv()__ with an |
|
|
69 |
automatic variable as the argument, then return from the |
|
|
70 |
calling function while ''string'' is still part of the |
|
|
71 |
environment.) However, glibc 2.0-2.1.1 differs: a copy of |
|
|
72 |
the string is used. On the one hand this causes a memory |
|
|
73 |
leak, and on the other hand it violates SUSv2. This has been |
|
|
74 |
fixed in glibc2.1.2. |
|
|
75 |
|
|
|
76 |
|
|
|
77 |
The BSD4.4 version, like glibc 2.0, uses a |
|
|
78 |
copy. |
|
|
79 |
|
|
|
80 |
|
|
|
81 |
SUSv2 removes the `const' from the prototype, and so does |
|
|
82 |
glibc 2.1.3. |
|
|
83 |
!!CONFORMING TO |
|
|
84 |
|
|
|
85 |
|
|
|
86 |
SVID 3, POSIX, BSD 4.3 |
|
|
87 |
!!SEE ALSO |
|
|
88 |
|
|
|
89 |
|
|
|
90 |
getenv(3), setenv(3), unsetenv(3), |
|
|
91 |
environ(7) |
|
|
92 |
---- |