Commit 4fe88e4c authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Revert D4832473: [Folly] Disable EnvUtil::setAsCurrentEnvironment() on platforms without clearenv()

Summary: This reverts commit a80aabb5a223264746ab45e3138d065bce5fe99c

Differential Revision: D4832473

fbshipit-source-id: 1a78d61f3f09f1064876a786c15601a091f4402b
parent 0fa94136
...@@ -44,14 +44,12 @@ EnvironmentState EnvironmentState::fromCurrentEnvironment() { ...@@ -44,14 +44,12 @@ EnvironmentState EnvironmentState::fromCurrentEnvironment() {
return EnvironmentState{std::move(data)}; return EnvironmentState{std::move(data)};
} }
#if __linux__ && !FOLLY_MOBILE
void EnvironmentState::setAsCurrentEnvironment() { void EnvironmentState::setAsCurrentEnvironment() {
PCHECK(0 == clearenv()); PCHECK(0 == clearenv());
for (const auto& kvp : env_) { for (const auto& kvp : env_) {
PCHECK(0 == setenv(kvp.first.c_str(), kvp.second.c_str(), (int)true)); PCHECK(0 == setenv(kvp.first.c_str(), kvp.second.c_str(), (int)true));
} }
} }
#endif
std::vector<std::string> EnvironmentState::toVector() const { std::vector<std::string> EnvironmentState::toVector() const {
std::vector<std::string> result; std::vector<std::string> result;
......
...@@ -64,14 +64,12 @@ struct EnvironmentState { ...@@ -64,14 +64,12 @@ struct EnvironmentState {
return &env_; return &env_;
} }
#if __linux__ && !FOLLY_MOBILE
// Update the process environment with the one in the stored model. // Update the process environment with the one in the stored model.
// Subsequent changes to the model do not alter the process environment. The // Subsequent changes to the model do not alter the process environment. The
// state of the process environment during execution of this method is not // state of the process environment during execution of this method is not
// defined. If the process environment is altered by another thread during the // defined. If the process environment is altered by another thread during the
// execution of this method the results are not defined. // execution of this method the results are not defined.
void setAsCurrentEnvironment(); void setAsCurrentEnvironment();
#endif
// Get a copy of the model environment in the form used by `folly::Subprocess` // Get a copy of the model environment in the form used by `folly::Subprocess`
std::vector<std::string> toVector() const; std::vector<std::string> toVector() const;
......
...@@ -132,7 +132,6 @@ TEST(EnvironmentStateTest, Separation) { ...@@ -132,7 +132,6 @@ TEST(EnvironmentStateTest, Separation) {
EXPECT_STREQ("foon", getenv("spork")); EXPECT_STREQ("foon", getenv("spork"));
} }
#if __linux__ && !FOLLY_MOBILE
TEST(EnvironmentStateTest, Update) { TEST(EnvironmentStateTest, Update) {
EnvVarSaver saver{}; EnvVarSaver saver{};
auto env = EnvironmentState::fromCurrentEnvironment(); auto env = EnvironmentState::fromCurrentEnvironment();
...@@ -142,7 +141,6 @@ TEST(EnvironmentStateTest, Update) { ...@@ -142,7 +141,6 @@ TEST(EnvironmentStateTest, Update) {
env.setAsCurrentEnvironment(); env.setAsCurrentEnvironment();
EXPECT_STREQ("foon", getenv("spork")); EXPECT_STREQ("foon", getenv("spork"));
} }
#endif
TEST(EnvironmentStateTest, forSubprocess) { TEST(EnvironmentStateTest, forSubprocess) {
auto env = EnvironmentState::empty(); auto env = EnvironmentState::empty();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment