Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

setenv - Add or change environment variable

&pagelevel(4)&pagelevel

Definition

#include <stdlib.h>

int setenv (const char *envname, const char *envval, int overwrite);

The setenv function updates or adds a variable in the environment of the calling process.

The envname argument points to a string containing the name of an environment variable to
be added or altered. If the environment variable already exists, two cases must be
distinguished: If the value of overwrite is not zero, the environment is changed; if the value is zero,
the environment remains unchanged. In both cases the function is terminated successfully.

If the application modifies environ or the pointers to which it points, the behavior of setenv
is undefined. The setenv function updates the list of pointers to which environ points.

The strings described by envname and envval are copied by this function.

Return val.

0

-1

if successful.

otherwise. errno is set to indicate the error. The environment remains
unchanged.

See also

environ, getenv, malloc, putenv, unsetenv, stdlib.h, section “Environment variables”.