summaryrefslogtreecommitdiffstats
path: root/base/process_util_linux.cc
diff options
context:
space:
mode:
authorstuartmorgan@google.com <stuartmorgan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-06 20:03:01 +0000
committerstuartmorgan@google.com <stuartmorgan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-06 20:03:01 +0000
commit2aea9e09fb8fef9b318d04e241726651c9e87b31 (patch)
tree32e7664ec7af10d0c48197e9608f1913e38479f4 /base/process_util_linux.cc
parentc9df809a7979d30bd42c3015fd21fedfecbdf1a6 (diff)
downloadchromium_src-2aea9e09fb8fef9b318d04e241726651c9e87b31.zip
chromium_src-2aea9e09fb8fef9b318d04e241726651c9e87b31.tar.gz
chromium_src-2aea9e09fb8fef9b318d04e241726651c9e87b31.tar.bz2
Remove the Mac-specific implementation of LaunchApp, and share the Linux version.
Fixes a race condition with file descriptors, and gives the Mac access to the environment-alterning version of LaunchApp BUG=11174 TEST=Launching render/plugin/utility processes should still work on the Mac Review URL: http://codereview.chromium.org/165067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22649 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_linux.cc')
-rw-r--r--base/process_util_linux.cc77
1 files changed, 0 insertions, 77 deletions
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc
index 50eb4a2..a05e9bb 100644
--- a/base/process_util_linux.cc
+++ b/base/process_util_linux.cc
@@ -13,7 +13,6 @@
#include <string>
-#include "base/eintr_wrapper.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/string_tokenizer.h"
@@ -86,82 +85,6 @@ FilePath GetProcessExecutablePath(ProcessHandle process) {
return FilePath(std::string(exename, len));
}
-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) {
- 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));
- }
-
- 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);
- }
- }
- }
-
- // Obscure fork() rule: in the child, if you don't end up doing exec*(),
- // you call _exit() instead of exit(). This is because _exit() does not
- // call any previously-registered (in the parent) exit handlers, which
- // might do things like block waiting for threads that don't even exist
- // in the child.
- 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;
- _exit(127);
- } else {
- // Parent process
- if (wait)
- HANDLE_EINTR(waitpid(pid, 0, 0));
-
- if (process_handle)
- *process_handle = pid;
- }
-
- return true;
-}
-
-bool LaunchApp(const std::vector<std::string>& argv,
- const file_handle_mapping_vector& fds_to_remap,
- bool wait, ProcessHandle* process_handle) {
- base::environment_vector no_env;
- return LaunchApp(argv, no_env, fds_to_remap, wait, process_handle);
-}
-
-bool LaunchApp(const CommandLine& cl,
- bool wait, bool start_hidden,
- ProcessHandle* process_handle) {
- file_handle_mapping_vector no_files;
- return LaunchApp(cl.argv(), no_files, wait, process_handle);
-}
-
NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name,
const ProcessFilter* filter)
: executable_name_(executable_name), filter_(filter) {