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

Unified Diff: content/zygote/zygote_linux.cc

Issue 240673002: Simplify ZygoteForkDelegate API further (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't leak real PID to NaCl child processes Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/common/zygote_fork_delegate_linux.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/zygote/zygote_linux.cc
diff --git a/content/zygote/zygote_linux.cc b/content/zygote/zygote_linux.cc
index 04e9d830dfab935674277455d7ad0a8519cc28eb..63c472fa7e7167340fafbc21a1ce135e605f2162 100644
--- a/content/zygote/zygote_linux.cc
+++ b/content/zygote/zygote_linux.cc
@@ -333,7 +333,7 @@ int Zygote::ForkWithRealPid(const std::string& process_type,
fds.push_back(ipc_channel_fd); // kBrowserFDIndex
fds.push_back(dummy_fd); // kDummyFDIndex
fds.push_back(pipe_fds[0]); // kParentFDIndex
- pid = helper_->Fork(process_type, fds);
+ pid = helper_->Fork(process_type, fds, channel_id);
} else {
pid = fork();
}
@@ -410,18 +410,14 @@ int Zygote::ForkWithRealPid(const std::string& process_type,
process_info_map_[real_pid].internal_pid = pid;
process_info_map_[real_pid].started_from_helper = use_helper;
- if (use_helper) {
- if (!helper_->AckChild(pipe_fds[1], channel_id)) {
- LOG(ERROR) << "Failed to synchronise with zygote fork helper";
- goto error;
- }
- } else {
- int written =
- HANDLE_EINTR(write(pipe_fds[1], &real_pid, sizeof(real_pid)));
- if (written != sizeof(real_pid)) {
- LOG(ERROR) << "Failed to synchronise with child process";
- goto error;
- }
+ // If we're using a helper, we still need to let the child process know
+ // we've discovered its real PID, but we don't actually reveal the PID.
+ const base::ProcessId pid_for_child = use_helper ? 0 : real_pid;
+ ssize_t written =
+ HANDLE_EINTR(write(pipe_fds[1], &pid_for_child, sizeof(pid_for_child)));
+ if (written != sizeof(pid_for_child)) {
+ LOG(ERROR) << "Failed to synchronise with child process";
+ goto error;
}
close(pipe_fds[1]);
return real_pid;
« no previous file with comments | « content/public/common/zygote_fork_delegate_linux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698