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

Side by Side Diff: base/multiprocess_test.h

Issue 14497: POSIX: don't leak FDs when launching child Processes. (Closed)
Patch Set: Fix Windows Compilation Created 12 years 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/base.xcodeproj/project.pbxproj ('k') | base/process_util.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 #ifndef BASE_MULTIPROCESS_TEST_H__ 5 #ifndef BASE_MULTIPROCESS_TEST_H__
6 #define BASE_MULTIPROCESS_TEST_H__ 6 #define BASE_MULTIPROCESS_TEST_H__
7 7
8 #include "base/base_switches.h" 8 #include "base/base_switches.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // Returns the handle to the child, or NULL on failure 59 // Returns the handle to the child, or NULL on failure
60 // 60 //
61 // TODO(darin): re-enable this once we have base/debug_util.h 61 // TODO(darin): re-enable this once we have base/debug_util.h
62 // ProcessDebugFlags(&cl, DebugUtil::UNKNOWN, false); 62 // ProcessDebugFlags(&cl, DebugUtil::UNKNOWN, false);
63 base::ProcessHandle SpawnChild(const std::wstring& procname) { 63 base::ProcessHandle SpawnChild(const std::wstring& procname) {
64 return SpawnChild(procname, false); 64 return SpawnChild(procname, false);
65 } 65 }
66 66
67 base::ProcessHandle SpawnChild(const std::wstring& procname, 67 base::ProcessHandle SpawnChild(const std::wstring& procname,
68 bool debug_on_start) { 68 bool debug_on_start) {
69 #if defined(OS_WIN)
70 return SpawnChildImpl(procname, false);
71 #elif defined(OS_POSIX)
72 base::file_handle_mapping_vector empty_file_list;
73 return SpawnChildImpl(procname, empty_file_list, false);
74 #endif
75 }
76
77 #if defined(OS_POSIX)
78 base::ProcessHandle SpawnChild(
79 const std::wstring& procname,
80 const base::file_handle_mapping_vector& fds_to_map,
81 bool debug_on_start) {
82 return SpawnChildImpl(procname, fds_to_map, false);
83 }
84
85 #endif
86
87 private:
88 #if defined(OS_WIN)
89 base::ProcessHandle SpawnChildImpl(
90 const std::wstring& procname,
91 bool debug_on_start) {
69 CommandLine cl; 92 CommandLine cl;
70 base::ProcessHandle handle = static_cast<base::ProcessHandle>(NULL); 93 base::ProcessHandle handle = static_cast<base::ProcessHandle>(NULL);
71
72 #if defined(OS_WIN)
73 std::wstring clstr = cl.command_line_string(); 94 std::wstring clstr = cl.command_line_string();
74 CommandLine::AppendSwitchWithValue(&clstr, kRunClientProcess, procname); 95 CommandLine::AppendSwitchWithValue(&clstr, kRunClientProcess, procname);
75 96
76 if (debug_on_start) { 97 if (debug_on_start) {
77 CommandLine::AppendSwitch(&clstr, switches::kDebugOnStart); 98 CommandLine::AppendSwitch(&clstr, switches::kDebugOnStart);
78 } 99 }
79 100
80 base::LaunchApp(clstr, false, true, &handle); 101 base::LaunchApp(clstr, false, true, &handle);
102 return handle;
103 }
81 #elif defined(OS_POSIX) 104 #elif defined(OS_POSIX)
105 base::ProcessHandle SpawnChildImpl(
106 const std::wstring& procname,
107 const base::file_handle_mapping_vector& fds_to_map,
108 bool debug_on_start) {
109 CommandLine cl;
110 base::ProcessHandle handle = static_cast<base::ProcessHandle>(NULL);
111
82 std::vector<std::string> clvec(cl.argv()); 112 std::vector<std::string> clvec(cl.argv());
83 std::wstring wswitchstr = 113 std::wstring wswitchstr =
84 CommandLine::PrefixedSwitchStringWithValue(kRunClientProcess, 114 CommandLine::PrefixedSwitchStringWithValue(kRunClientProcess,
85 procname); 115 procname);
86 if (debug_on_start) { 116 if (debug_on_start) {
87 CommandLine::AppendSwitch(&wswitchstr, switches::kDebugOnStart); 117 CommandLine::AppendSwitch(&wswitchstr, switches::kDebugOnStart);
88 } 118 }
89 119
90 std::string switchstr = WideToUTF8(wswitchstr); 120 std::string switchstr = WideToUTF8(wswitchstr);
91 clvec.push_back(switchstr.c_str()); 121 clvec.push_back(switchstr.c_str());
92 base::LaunchApp(clvec, false, &handle); 122 base::LaunchApp(clvec, fds_to_map, false, &handle);
93 #endif
94
95 return handle; 123 return handle;
96 } 124 }
125 #endif
97 }; 126 };
98 127
99 #endif // BASE_MULTIPROCESS_TEST_H__ 128 #endif // BASE_MULTIPROCESS_TEST_H__
OLDNEW
« no previous file with comments | « base/base.xcodeproj/project.pbxproj ('k') | base/process_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698