flushenv

Creates or overwrites a variable in the host (or master) environment, which does not affect any NLM applications that are currently loaded.

Library:LibC
Classification:ANSI
Service:Environment Variable

Syntax

  #include <stdlib.h> 
   
  int flushenv (
     const char   *string,
     int           overwrite); 
  

Parameters

string

(IN) Points to a string that contains the name of an environment variable and its value in the form:

     "name=value"
  

The “name” is composed of characters in 7-bit ASCII and can be up to ENV_NAME_MAX (80) characters in length. The name is followed by an equal sign (0x3D), and it is followed by “value,” which is an ASCIIZ string.

overwrite

(IN) Specifies what action flushenv takes, if the variable already exists in the host environment:

  • Zero An existing variable is not overwritten
  • Nonzero An existing variable is overwritten

Return Values

If successful, returns 0. Otherwise, returns a -1 and sets errno to one of the following:

Decimal

Constant

Description

5

ENOMEM

Not enough memory.

7

EEXIST

The variable already exists.

65

ENAMETOOLONG

The name of the environment variable is greater than the maximum allowed length.

105

ENOCONTEXT

No thread context is present.

Remarks

The flushenv function does not change the application's environment.It changes the environment for the applications that are loaded after the function is called.

WARNING:Calling flushenv can be potentially destabilizing or even destructive to a server. You should fully understand how flushenv works before calling it.

See Also