diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-11 15:25:54 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-11 15:25:54 +0000 |
commit | ef73044e42948214832dd11dd3326b738f816eb6 (patch) | |
tree | 1105589709517fab2cc2ed5d745d82299d510f77 /base/process_util.h | |
parent | 6e240d7084c1cecc7fdedabe83f860659888dd2f (diff) | |
download | chromium_src-ef73044e42948214832dd11dd3326b738f816eb6.zip chromium_src-ef73044e42948214832dd11dd3326b738f816eb6.tar.gz chromium_src-ef73044e42948214832dd11dd3326b738f816eb6.tar.bz2 |
POSIX: don't allocate memory after forking.
Previously we would allocate memory in the child process. However, the
allocation might have happened while the malloc lock was held,
resulting in a deadlock.
This patch removes allocation from the child but probably makes Mac's
startup time slower until a Mac person can implement
dir_reader_posix.h.
TEST=Unittest for new code
BUG=36678
http://codereview.chromium.org/672003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41275 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util.h')
-rw-r--r-- | base/process_util.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/base/process_util.h b/base/process_util.h index cf4bd01..f471ac0 100644 --- a/base/process_util.h +++ b/base/process_util.h @@ -111,12 +111,6 @@ bool AdjustOOMScore(ProcessId process, int score); #endif #if defined(OS_POSIX) -// Sets all file descriptors to close on exec except for stdin, stdout -// and stderr. -// TODO(agl): remove this function -// WARNING: do not use. It's inherently race-prone in the face of -// multi-threading. -void SetAllFDsToCloseOnExec(); // Close all file descriptors, expect those which are a destination in the // given multimap. Only call this function in a child process where you know // that there aren't any other threads. @@ -185,6 +179,16 @@ bool LaunchApp(const std::vector<std::string>& argv, const file_handle_mapping_vector& fds_to_remap, bool wait, ProcessHandle* process_handle); +// AlterEnvironment returns a modified environment vector, constructed from the +// given environment and the list of changes given in |changes|. Each key in +// the environment is matched against the first element of the pairs. In the +// event of a match, the value is replaced by the second of the pair, unless +// the second is empty, in which case the key-value is removed. +// +// The returned array is allocated using new[] and must be freed by the caller. +char** AlterEnvironment(const environment_vector& changes, + const char* const* const env); + #if defined(OS_MACOSX) // Similar to the above, but also returns the new process's task_t if // |task_handle| is not NULL. If |task_handle| is not NULL, the caller is |