Clear the environment
#include <stdlib.h> int clearenv( void );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The clearenv() function clears the environment area; no environment variables are defined immediately after the clearenv() call.
Note that clearenv() clears the following environment variables, which may then affect the operation of other library functions such as spawnp():
Clear the entire environment and set up a new TZ environment variable:
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
if( clearenv() != 0 ) {
puts( "Unable to clear the environment" );
return EXIT_FAILURE;
}
setenv( "TZ", "EST5EDT", 0 );
return EXIT_SUCCESS;
}
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | No |
| Thread | Yes |
The clearenv() function manipulates the environment pointed to by the global environ variable.