Index: net/test/test_server_posix.cc |
diff --git a/net/test/test_server_posix.cc b/net/test/test_server_posix.cc |
index 7741d895f4d35dc683f5bc57637a77764755d008..262845c1749d79a945bd23b73baa102a1353aed3 100644 |
--- a/net/test/test_server_posix.cc |
+++ b/net/test/test_server_posix.cc |
@@ -32,8 +32,22 @@ bool TestServer::LaunchPython(const FilePath& testserver_path) { |
if (type_ == TYPE_HTTPS_CLIENT_AUTH) |
command_line.push_back("--ssl-client-auth"); |
- base::file_handle_mapping_vector no_mappings; |
- if (!base::LaunchApp(command_line, no_mappings, false, &process_handle_)) { |
+ int pipefd[2]; |
+ if (pipe(pipefd) != 0) { |
+ PLOG(ERROR) << "Could not create pipe."; |
+ return false; |
+ } |
+ |
+ // Save the read half. The write half is sent to the child. |
+ child_fd_ = pipefd[0]; |
+ child_fd_closer_.reset(&child_fd_); |
+ file_util::ScopedFD write_closer(&pipefd[1]); |
+ base::file_handle_mapping_vector map_write_fd; |
+ map_write_fd.push_back(std::make_pair(pipefd[1], pipefd[1])); |
+ |
+ command_line.push_back("--startup-pipe=" + base::IntToString(pipefd[1])); |
+ |
+ if (!base::LaunchApp(command_line, map_write_fd, false, &process_handle_)) { |
LOG(ERROR) << "Failed to launch " << command_line[0] << " ..."; |
return false; |
} |
@@ -41,6 +55,14 @@ bool TestServer::LaunchPython(const FilePath& testserver_path) { |
return true; |
} |
+bool TestServer::WaitToStart() { |
+ char buf[8]; |
+ ssize_t n = HANDLE_EINTR(read(child_fd_, buf, sizeof(buf))); |
+ // We don't need the FD anymore. |
+ child_fd_closer_.reset(NULL); |
+ return n > 0; |
+} |
+ |
bool TestServer::CheckCATrusted() { |
return true; |
} |