clearenv

clear the process environment area

Synopsis:

int clearenv( void );
#include <env.h>

Description:

The clearenv() function clears the process environment area. No environment variables are defined immediately after a call to it. Note that this clears the following environment variables, which may then affect the operation of other library functions:

The clearenv() function may manipulate the value of the pointer environ.

Returns:

0
Success
(-1)
An error occurred. errno is set to indicate the error.

Errors:

ENOMEM
Not enough memory to allocate a control structure.

See also:

errno, exec... functions, getenv(), putenv(), _searchenv(), searchenv(), setenv(), spawn... functions, system()

Examples:

The following example clears the entire environment area and sets up a new TZ environment variable.

#include <env.h>

void main()
  {
    clearenv();
    setenv( "TZ", "EST5EDT", 0 );
  }

Classification:

POSIX 1003.1

Systems:

All (except Netware, DOS/PM)