rcutils  master
C API providing common utilities and data structures.
Functions
env.h File Reference
#include <stdbool.h>
#include "rcutils/macros.h"
#include "rcutils/visibility_control.h"
#include "rcutils/get_env.h"
Include dependency graph for env.h:

Go to the source code of this file.

Functions

bool rcutils_set_env (const char *env_name, const char *env_value)
 Set or un-set a process-scoped environment variable. More...
 

Function Documentation

◆ rcutils_set_env()

bool rcutils_set_env ( const char *  env_name,
const char *  env_value 
)

Set or un-set a process-scoped environment variable.

This function modifies the environment variables for the current process by copying given string values into the process' global environment variable store.

Thread Safety:
This function is not thread-safe. Take care not to modify the environment variables while another thread might be reading or writing environment variables.
Platform Consistency:
The behavior when setting a variable to an empty string ("") differs between platforms. On Windows, the variable is un-set (as if env_value was NULL), while on other platforms the variable is set to an empty string as expected.
Parameters
[in]env_nameName of the environment variable to modify.
[in]env_valueValue to set the environment variable to, or NULL to un-set.
Returns
true if success, or
false if env_name is invalid or NULL, or
false on failure.