Your Browser is not longer supported

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

{{viewport.spaceProperty.prod}}

unsetenv - remove an environment variable

&pagelevel(4)&pagelevel

Syntax

#include <stdlib.h>

int unsetenv (const char *name); 

Description

The unsetenv() function removes an environment variable from the environment of the calling process.

The name argument points to a string, which is the name of the variable to be removed. This string shall not contain an '=' character. If the named variable does not exist in the current environment, the environment remains unchanged and the function is considered to have completed successfully.

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

unsetenv() is not thread-save.

Return val.

0

-1

if successful.

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

Errors

unsetenv() will fail if:

EINVAL

The name argument is a null pointer, points to an empty string, or points to a string containing an '=' character.

See also

environ, exec, getenv(), malloc(), putenv(), setenv(), stdlib.h, section “Environment variables”.