unsetenv() — Delete an environment variable

Standards

Standards / Extensions C or C++ Dependencies

Single UNIX Specification, version 3

both

z/OS V1R7

Format

#define _UNIX03_SOURCE
#include <stdlib.h>

int unsetenv(const char *name);

General description

unsetenv() deletes 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. If the string pointed to by name contains an '=' character, unsetenv() will fail. If the named variable does not exist in the current environment, the environment will not be changed and unsetenv() will succeed.

Returned value

If successful, unsetenv() returns 0. If unsuccessful, unsetenv() returns -1 and sets errno to indicate the error.
  • EINVAL – The name argument is a null pointer, points to an empty string, or points to a string containing an '=' character.

Related information