Re: [Boost-bugs] [Boost C++ Libraries] #7018: operations_test.cpp does not correctly use setenv

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7018: operations_test.cpp does not correctly use setenv
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-07-05 21:59:35


#7018: operations_test.cpp does not correctly use setenv
--------------------------------------------------------------+-------------
  Reporter: Daniel Krügler <daniel.kruegler@…> | Owner: bemandawes
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: filesystem
   Version: Boost 1.49.0 | Severity: Problem
Resolution: | Keywords:
--------------------------------------------------------------+-------------

Comment (by Daniel Krügler <daniel.kruegler@…>):

 While I still think that the suggested changes are formally correct, I
 would like to mention that the usage of SetEnvironmentVariableW as a means
 to change the environment variables of the current process can be
 problematic for some runtimes, in particular for the MSV CRT. The problem
 here is, that albeit these functions properly update the environment
 variable values of the OS, they *won't* update the copies of these values
 kept by the CRT like _environ or any function that depends on these, e.g.
 std::getenv. Some details of this problem are explained here:

 http://www.codeproject.com/Articles/43029/When-what-you-set-is-not-what-
 you-get-SetEnvironme

 We recently stumbled across this very same problem when we used a similar
 approach to change the environment variables of the process by means of
 SetEnvironmentVariableW and wondered why our CORBA::ORB_init from OmniOrb
 didn't react as we expected: It queries getenv and the environment hasn't
 been changed for this function. The proper solution for MSVCRT-based
 systems is to use _putenv instead - it can be considered as the Microsoft
 pendant of the POSIX setenv function (It does *not* have the problematic
 semantics of the POSIX putenv function).

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7018#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC