diff options
author | stuartmorgan@google.com <stuartmorgan@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-06 20:03:01 +0000 |
---|---|---|
committer | stuartmorgan@google.com <stuartmorgan@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-06 20:03:01 +0000 |
commit | 2aea9e09fb8fef9b318d04e241726651c9e87b31 (patch) | |
tree | 32e7664ec7af10d0c48197e9608f1913e38479f4 /base/process_util_mac.mm | |
parent | c9df809a7979d30bd42c3015fd21fedfecbdf1a6 (diff) | |
download | chromium_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_mac.mm')
-rw-r--r-- | base/process_util_mac.mm | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/base/process_util_mac.mm b/base/process_util_mac.mm index 9653ada..de9b3f1 100644 --- a/base/process_util_mac.mm +++ b/base/process_util_mac.mm @@ -21,78 +21,6 @@ namespace base { -bool LaunchApp(const std::vector<std::string>& argv, - const file_handle_mapping_vector& fds_to_remap, - bool wait, ProcessHandle* process_handle) { - bool retval = true; - - char* argv_copy[argv.size() + 1]; - for (size_t i = 0; i < argv.size(); i++) { - argv_copy[i] = const_cast<char*>(argv[i].c_str()); - } - argv_copy[argv.size()] = NULL; - - // Make sure we don't leak any FDs to the child process by marking all FDs - // as close-on-exec. - SetAllFDsToCloseOnExec(); - - posix_spawn_file_actions_t file_actions; - if (posix_spawn_file_actions_init(&file_actions) != 0) { - return false; - } - - // Turn fds_to_remap array into a set of dup2 calls. - for (file_handle_mapping_vector::const_iterator it = fds_to_remap.begin(); - it != fds_to_remap.end(); - ++it) { - int src_fd = it->first; - int dest_fd = it->second; - - if (src_fd == dest_fd) { - int flags = fcntl(src_fd, F_GETFD); - if (flags != -1) { - fcntl(src_fd, F_SETFD, flags & ~FD_CLOEXEC); - } - } else { - if (posix_spawn_file_actions_adddup2(&file_actions, src_fd, dest_fd) != 0) - { - posix_spawn_file_actions_destroy(&file_actions); - return false; - } - } - } - - int pid = 0; - int spawn_succeeded = (posix_spawnp(&pid, - argv_copy[0], - &file_actions, - NULL, - argv_copy, - *_NSGetEnviron()) == 0); - - posix_spawn_file_actions_destroy(&file_actions); - - bool process_handle_valid = pid > 0; - if (!spawn_succeeded || !process_handle_valid) { - retval = false; - } else { - if (wait) - HANDLE_EINTR(waitpid(pid, 0, 0)); - - if (process_handle) - *process_handle = pid; - } - - return retval; -} - -bool LaunchApp(const CommandLine& cl, - bool wait, bool start_hidden, ProcessHandle* process_handle) { - // TODO(playmobil): Do we need to respect the start_hidden flag? - 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), |