1setenv(3C)               Standard C Library Functions               setenv(3C)
2
3
4

NAME

6       setenv - add or change environment variable
7

SYNOPSIS

9       #include <stdlib.h>
10
11       int setenv(const char *envname, const char *envval,
12            int overwrite);
13
14

DESCRIPTION

16       The  setenv() function updates or adds a variable in the environment of
17       the calling process.  The envname argument points to a string  contain‐
18       ing  the  name  of  an environment variable to be added or altered. The
19       environment variable is set to the value to which  envval  points.  The
20       function  fails  if  envname  points  to a string which contains an '='
21       character. If the environment variable named by envname already  exists
22       and  the  value of overwrite is non-zero, the function returns success‐
23       fully and the environment is updated. If the environment variable named
24       by envname already exists and the value of overwrite is zero, the func‐
25       tion returns successfully and the environment remains unchanged.
26
27
28       If the application modifies environ or the pointers to which it points,
29       the  behavior  of  setenv() is undefined. The setenv() function updates
30       the list of pointers to which environ points.
31
32
33       The strings described by envname and envval are copied  by  this  func‐
34       tion.
35

RETURN VALUES

37       Upon  successful  completion, 0 is returned. Otherwise, -1 is returned,
38       errno set to indicate the error, and the environment is left unchanged.
39

ERRORS

41       The setenv() function will fail if:
42
43       EINVAL    The envname argument is a null pointer, points  to  an  empty
44                 string, or points to a string containing an '=' character.
45
46
47       ENOMEM    Insufficient  memory  was  available to add a variable or its
48                 value to the environment.
49
50

ATTRIBUTES

52       See attributes(5) for descriptions of the following attributes:
53
54
55
56
57       ┌─────────────────────────────┬─────────────────────────────┐
58       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
59       ├─────────────────────────────┼─────────────────────────────┤
60       │Interface Stability          │Standard                     │
61       ├─────────────────────────────┼─────────────────────────────┤
62       │MT-Level                     │MT-Safe                      │
63       └─────────────────────────────┴─────────────────────────────┘
64

SEE ALSO

66       getenv(3C), unsetenv(3C), attributes(5), standards(5)
67
68
69
70SunOS 5.11                        31 Mar 2002                       setenv(3C)
Impressum