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, particularly when called concurrently with rcutils_get_env. 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
False if env_name is invalid or NULL
False on failure