Function rcutils_set_env_overwrite

Function Documentation

bool rcutils_set_env_overwrite(const char *env_name, const char *env_value, bool overwrite)

Set or un-set a process-scoped environment variable while specifying overwrite behavior.

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:
  • env_name[in] Name of the environment variable to modify.

  • env_value[in] Value to set the environment variable to, or NULL to un-set.

  • overwrite[in] If true, the environemnt variable value will not be overwritten if previously set.

Returns:

true if success, or

Returns:

false if env_name is invalid or NULL, or

Returns:

false on failure.