Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: base/process_util_mac.mm

Issue 18801: Add routine to close file descriptors on exec (Closed)
Patch Set: final cleanups Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/process_util_linux.cc ('k') | base/process_util_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/process_util.h" 7 #include "base/process_util.h"
8 8
9 #import <Cocoa/Cocoa.h> 9 #import <Cocoa/Cocoa.h>
10 #include <spawn.h> 10 #include <spawn.h>
(...skipping 13 matching lines...) Expand all
24 bool retval = true; 24 bool retval = true;
25 25
26 char* argv_copy[argv.size() + 1]; 26 char* argv_copy[argv.size() + 1];
27 for (size_t i = 0; i < argv.size(); i++) { 27 for (size_t i = 0; i < argv.size(); i++) {
28 argv_copy[i] = const_cast<char*>(argv[i].c_str()); 28 argv_copy[i] = const_cast<char*>(argv[i].c_str());
29 } 29 }
30 argv_copy[argv.size()] = NULL; 30 argv_copy[argv.size()] = NULL;
31 31
32 // Make sure we don't leak any FDs to the child process by marking all FDs 32 // Make sure we don't leak any FDs to the child process by marking all FDs
33 // as close-on-exec. 33 // as close-on-exec.
34 int max_files = GetMaxFilesOpenInProcess(); 34 SetAllFDsToCloseOnExec();
35 for (int i = STDERR_FILENO + 1; i < max_files; i++) {
36 int flags = fcntl(i, F_GETFD);
37 if (flags != -1) {
38 fcntl(i, F_SETFD, flags | FD_CLOEXEC);
39 }
40 }
41 35
42 posix_spawn_file_actions_t file_actions; 36 posix_spawn_file_actions_t file_actions;
43 if (posix_spawn_file_actions_init(&file_actions) != 0) { 37 if (posix_spawn_file_actions_init(&file_actions) != 0) {
44 return false; 38 return false;
45 } 39 }
46 40
47 // Turn fds_to_remap array into a set of dup2 calls. 41 // Turn fds_to_remap array into a set of dup2 calls.
48 for (file_handle_mapping_vector::const_iterator it = fds_to_remap.begin(); 42 for (file_handle_mapping_vector::const_iterator it = fds_to_remap.begin();
49 it != fds_to_remap.end(); 43 it != fds_to_remap.end();
50 ++it) { 44 ++it) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 103
110 bool CleanupProcesses(const std::wstring& executable_name, 104 bool CleanupProcesses(const std::wstring& executable_name,
111 int wait_milliseconds, 105 int wait_milliseconds,
112 int exit_code, 106 int exit_code,
113 const ProcessFilter* filter) { 107 const ProcessFilter* filter) {
114 NOTIMPLEMENTED(); 108 NOTIMPLEMENTED();
115 return false; 109 return false;
116 } 110 }
117 111
118 } // namespace base 112 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util_linux.cc ('k') | base/process_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698