summaryrefslogtreecommitdiffstats
path: root/base/multiprocess_test.h
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-17 22:41:50 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-17 22:41:50 +0000
commitfa3097a6a5ec6c6e7c092a6339c283dc34d42ca7 (patch)
tree7fc997f0a3cb9ce2aca5411e43c1987e6618b7d1 /base/multiprocess_test.h
parent6f666448fe72b6f98a241cb9d83a2a15aa4ff24e (diff)
downloadchromium_src-fa3097a6a5ec6c6e7c092a6339c283dc34d42ca7.zip
chromium_src-fa3097a6a5ec6c6e7c092a6339c283dc34d42ca7.tar.gz
chromium_src-fa3097a6a5ec6c6e7c092a6339c283dc34d42ca7.tar.bz2
* On POSIX, make sure we don't leak FDs when launching child Processes.
* Add a facility to LaunchProcess() to remap a given FD into a child process. This change is needed for 2 reasons: 1)We want to use a socketpair() for IPC, the child process needs a known FD # for it's side of the socket. 2)The OS X Sandbox doesn't close FDs. Review URL: http://codereview.chromium.org/14497 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7175 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/multiprocess_test.h')
-rw-r--r--base/multiprocess_test.h39
1 files changed, 34 insertions, 5 deletions
diff --git a/base/multiprocess_test.h b/base/multiprocess_test.h
index a9c67d5..c262b59 100644
--- a/base/multiprocess_test.h
+++ b/base/multiprocess_test.h
@@ -66,10 +66,31 @@ class MultiProcessTest : public PlatformTest {
base::ProcessHandle SpawnChild(const std::wstring& procname,
bool debug_on_start) {
- CommandLine cl;
- base::ProcessHandle handle = static_cast<base::ProcessHandle>(NULL);
+#if defined(OS_WIN)
+ return SpawnChildImpl(procname, debug_on_start);
+#elif defined(OS_POSIX)
+ base::file_handle_mapping_vector empty_file_list;
+ return SpawnChildImpl(procname, empty_file_list, false);
+#endif
+ }
+
+#if defined(OS_POSIX)
+ base::ProcessHandle SpawnChild(
+ const std::wstring& procname,
+ const base::file_handle_mapping_vector& fds_to_map,
+ bool debug_on_start) {
+ return SpawnChildImpl(procname, fds_to_map, false);
+ }
+
+#endif
+ private:
#if defined(OS_WIN)
+ base::ProcessHandle SpawnChildImpl(
+ const std::wstring& procname,
+ bool debug_on_start) {
+ CommandLine cl;
+ base::ProcessHandle handle = static_cast<base::ProcessHandle>(NULL);
std::wstring clstr = cl.command_line_string();
CommandLine::AppendSwitchWithValue(&clstr, kRunClientProcess, procname);
@@ -78,7 +99,16 @@ class MultiProcessTest : public PlatformTest {
}
base::LaunchApp(clstr, false, true, &handle);
+ return handle;
+ }
#elif defined(OS_POSIX)
+ base::ProcessHandle SpawnChildImpl(
+ const std::wstring& procname,
+ const base::file_handle_mapping_vector& fds_to_map,
+ bool debug_on_start) {
+ CommandLine cl;
+ base::ProcessHandle handle = static_cast<base::ProcessHandle>(NULL);
+
std::vector<std::string> clvec(cl.argv());
std::wstring wswitchstr =
CommandLine::PrefixedSwitchStringWithValue(kRunClientProcess,
@@ -89,11 +119,10 @@ class MultiProcessTest : public PlatformTest {
std::string switchstr = WideToUTF8(wswitchstr);
clvec.push_back(switchstr.c_str());
- base::LaunchApp(clvec, false, &handle);
-#endif
-
+ base::LaunchApp(clvec, fds_to_map, false, &handle);
return handle;
}
+#endif
};
#endif // BASE_MULTIPROCESS_TEST_H__