replace "leaky" call to putenv() with setenv() on non-windows platforms

This commit is contained in:
Axel Kohlmeyer
2021-04-09 20:37:01 -04:00
parent a69c5a5cae
commit c16e4f241f
2 changed files with 19 additions and 12 deletions

View File

@ -1252,7 +1252,16 @@ void Input::shell()
#ifdef _WIN32
if (arg[i]) rv = _putenv(utils::strdup(arg[i]));
#else
if (arg[i]) rv = putenv(utils::strdup(arg[i]));
if (arg[i]) {
std::string vardef(arg[i]);
auto found = vardef.find_first_of("=");
if (found == std::string::npos) {
rv = setenv(vardef.c_str(),"",1);
} else {
rv = setenv(vardef.substr(0,found).c_str(),
vardef.substr(found+1).c_str(),1);
}
}
#endif
rv = (rv < 0) ? errno : 0;
MPI_Reduce(&rv,&err,1,MPI_INT,MPI_MAX,0,world);