From 4fe88e4c921168ffbc53ccfa5210d9b9721d9f29 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Mon, 10 Apr 2017 19:23:54 -0700 Subject: [PATCH 1/1] Revert D4832473: [Folly] Disable EnvUtil::setAsCurrentEnvironment() on platforms without clearenv() Summary: This reverts commit a80aabb5a223264746ab45e3138d065bce5fe99c Differential Revision: D4832473 fbshipit-source-id: 1a78d61f3f09f1064876a786c15601a091f4402b --- folly/experimental/EnvUtil.cpp | 2 -- folly/experimental/EnvUtil.h | 2 -- folly/experimental/test/EnvUtilTest.cpp | 2 -- 3 files changed, 6 deletions(-) diff --git a/folly/experimental/EnvUtil.cpp b/folly/experimental/EnvUtil.cpp index 1035575d..5c16ee74 100644 --- a/folly/experimental/EnvUtil.cpp +++ b/folly/experimental/EnvUtil.cpp @@ -44,14 +44,12 @@ EnvironmentState EnvironmentState::fromCurrentEnvironment() { return EnvironmentState{std::move(data)}; } -#if __linux__ && !FOLLY_MOBILE void EnvironmentState::setAsCurrentEnvironment() { PCHECK(0 == clearenv()); for (const auto& kvp : env_) { PCHECK(0 == setenv(kvp.first.c_str(), kvp.second.c_str(), (int)true)); } } -#endif std::vector EnvironmentState::toVector() const { std::vector result; diff --git a/folly/experimental/EnvUtil.h b/folly/experimental/EnvUtil.h index 3ab06164..3ab3b16a 100644 --- a/folly/experimental/EnvUtil.h +++ b/folly/experimental/EnvUtil.h @@ -64,14 +64,12 @@ struct EnvironmentState { return &env_; } -#if __linux__ && !FOLLY_MOBILE // Update the process environment with the one in the stored model. // Subsequent changes to the model do not alter the process environment. The // state of the process environment during execution of this method is not // defined. If the process environment is altered by another thread during the // execution of this method the results are not defined. void setAsCurrentEnvironment(); -#endif // Get a copy of the model environment in the form used by `folly::Subprocess` std::vector toVector() const; diff --git a/folly/experimental/test/EnvUtilTest.cpp b/folly/experimental/test/EnvUtilTest.cpp index 1e1e3d2d..bcac455d 100644 --- a/folly/experimental/test/EnvUtilTest.cpp +++ b/folly/experimental/test/EnvUtilTest.cpp @@ -132,7 +132,6 @@ TEST(EnvironmentStateTest, Separation) { EXPECT_STREQ("foon", getenv("spork")); } -#if __linux__ && !FOLLY_MOBILE TEST(EnvironmentStateTest, Update) { EnvVarSaver saver{}; auto env = EnvironmentState::fromCurrentEnvironment(); @@ -142,7 +141,6 @@ TEST(EnvironmentStateTest, Update) { env.setAsCurrentEnvironment(); EXPECT_STREQ("foon", getenv("spork")); } -#endif TEST(EnvironmentStateTest, forSubprocess) { auto env = EnvironmentState::empty(); -- 2.34.1