diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 17:05:54 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-21 17:05:54 +0000 |
commit | e65723081b1f5e0a2fd1fddd411fe64806a9d7ef (patch) | |
tree | fc91b4c816f1427dfc8b39c71f186404cd77c8c7 /base/process_util_posix.cc | |
parent | 3c8258e229ccee5b86c758fbdcdf7644d2055cf1 (diff) | |
download | chromium_src-e65723081b1f5e0a2fd1fddd411fe64806a9d7ef.zip chromium_src-e65723081b1f5e0a2fd1fddd411fe64806a9d7ef.tar.gz chromium_src-e65723081b1f5e0a2fd1fddd411fe64806a9d7ef.tar.bz2 |
Revert r23911, which switched from fork to vfork().
Everything still worked correctly, but our performance bots didn't measure
any improvements. Perhaps I just ended up measuring the dtrace overhead of
fork vs vfork.
BUG=19863
Review URL: http://codereview.chromium.org/174229
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23969 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_posix.cc')
-rw-r--r-- | base/process_util_posix.cc | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index d81776f..ecb4937 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -224,40 +224,25 @@ bool LaunchApp(const std::vector<std::string>& argv, const environment_vector& environ, const file_handle_mapping_vector& fds_to_remap, bool wait, ProcessHandle* process_handle) { - // We call vfork() for additional performance (avoids touching the page - // tables). This makes things a bit more dangerous since the child and - // parent share the same address space and stack. Try to do most of our - // operations before the fork, and hope that everything we do have to do - // will be ok... - bool use_vfork = (environ.size() == 0); - - InjectiveMultimap fd_shuffle; - for (file_handle_mapping_vector::const_iterator - it = fds_to_remap.begin(); it != fds_to_remap.end(); ++it) { - fd_shuffle.push_back(InjectionArc(it->first, it->second, false)); - } - - scoped_array<char*> argv_cstr(new char*[argv.size() + 1]); - for (size_t i = 0; i < argv.size(); i++) - argv_cstr[i] = const_cast<char*>(argv[i].c_str()); - argv_cstr[argv.size()] = NULL; - - pid_t pid = use_vfork ? vfork() : fork(); + pid_t pid = fork(); if (pid < 0) return false; if (pid == 0) { // Child process + InjectiveMultimap fd_shuffle; + for (file_handle_mapping_vector::const_iterator + it = fds_to_remap.begin(); it != fds_to_remap.end(); ++it) { + fd_shuffle.push_back(InjectionArc(it->first, it->second, false)); + } - if (!use_vfork) { - for (environment_vector::const_iterator it = environ.begin(); - it != environ.end(); ++it) { - if (it->first) { - if (it->second) { - setenv(it->first, it->second, 1); - } else { - unsetenv(it->first); - } + for (environment_vector::const_iterator it = environ.begin(); + it != environ.end(); ++it) { + if (it->first) { + if (it->second) { + setenv(it->first, it->second, 1); + } else { + unsetenv(it->first); } } } @@ -270,8 +255,17 @@ bool LaunchApp(const std::vector<std::string>& argv, if (!ShuffleFileDescriptors(fd_shuffle)) _exit(127); + // If we are using the SUID sandbox, it sets a magic environment variable + // ("SBX_D"), so we remove that variable from the environment here on the + // off chance that it's already set. + unsetenv("SBX_D"); + CloseSuperfluousFds(fd_shuffle); + scoped_array<char*> argv_cstr(new char*[argv.size() + 1]); + for (size_t i = 0; i < argv.size(); i++) + argv_cstr[i] = const_cast<char*>(argv[i].c_str()); + argv_cstr[argv.size()] = NULL; execvp(argv_cstr[0], argv_cstr.get()); LOG(ERROR) << "LaunchApp: exec failed!, argv_cstr[0] " << argv_cstr[0] << ", errno " << errno; |