summaryrefslogtreecommitdiff
path: root/runtime/runtime.h
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/runtime.h')
-rw-r--r--runtime/runtime.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 6da60f27a3..5f89d6adca 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -642,6 +642,12 @@ class Runtime {
// optimization that makes it impossible to deoptimize.
bool IsDeoptimizeable(uintptr_t code) const SHARED_REQUIRES(Locks::mutator_lock_);
+ // Returns a saved copy of the environment (getenv/setenv values).
+ // Used by Fork to protect against overwriting LD_LIBRARY_PATH, etc.
+ char** GetEnvSnapshot() const {
+ return env_snapshot_.GetSnapshot();
+ }
+
private:
static void InitPlatformSignalHandlers();
@@ -864,6 +870,20 @@ class Runtime {
// Whether zygote code is in a section that should not start threads.
bool zygote_no_threads_;
+ // Saved environment.
+ class EnvSnapshot {
+ public:
+ EnvSnapshot() = default;
+ void TakeSnapshot();
+ char** GetSnapshot() const;
+
+ private:
+ std::unique_ptr<char*[]> c_env_vector_;
+ std::vector<std::unique_ptr<std::string>> name_value_pairs_;
+
+ DISALLOW_COPY_AND_ASSIGN(EnvSnapshot);
+ } env_snapshot_;
+
DISALLOW_COPY_AND_ASSIGN(Runtime);
};
std::ostream& operator<<(std::ostream& os, const Runtime::CalleeSaveType& rhs);