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

Side by Side Diff: content/zygote/zygote_linux.cc

Issue 809243002: Use ForkWithFlags on the zygote. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Explain reasons for using ForkWithFlags. Created 6 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 | « no previous file | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/zygote/zygote_linux.h" 5 #include "content/zygote/zygote_linux.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <string.h> 8 #include <string.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 15 matching lines...) Expand all
26 #include "content/common/sandbox_linux/sandbox_linux.h" 26 #include "content/common/sandbox_linux/sandbox_linux.h"
27 #include "content/common/set_process_title.h" 27 #include "content/common/set_process_title.h"
28 #include "content/common/zygote_commands_linux.h" 28 #include "content/common/zygote_commands_linux.h"
29 #include "content/public/common/content_descriptors.h" 29 #include "content/public/common/content_descriptors.h"
30 #include "content/public/common/result_codes.h" 30 #include "content/public/common/result_codes.h"
31 #include "content/public/common/sandbox_linux.h" 31 #include "content/public/common/sandbox_linux.h"
32 #include "content/public/common/send_zygote_child_ping_linux.h" 32 #include "content/public/common/send_zygote_child_ping_linux.h"
33 #include "content/public/common/zygote_fork_delegate_linux.h" 33 #include "content/public/common/zygote_fork_delegate_linux.h"
34 #include "ipc/ipc_channel.h" 34 #include "ipc/ipc_channel.h"
35 #include "ipc/ipc_switches.h" 35 #include "ipc/ipc_switches.h"
36 #include "sandbox/linux/services/syscall_wrappers.h"
36 37
37 #if defined(ADDRESS_SANITIZER) 38 #if defined(ADDRESS_SANITIZER)
38 #include <sanitizer/asan_interface.h> 39 #include <sanitizer/asan_interface.h>
39 #endif 40 #endif
40 41
41 // See http://code.google.com/p/chromium/wiki/LinuxZygote 42 // See http://code.google.com/p/chromium/wiki/LinuxZygote
42 43
43 namespace content { 44 namespace content {
44 45
45 namespace { 46 namespace {
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 368 }
368 std::vector<int> fds; 369 std::vector<int> fds;
369 fds.push_back(ipc_channel_fd); // kBrowserFDIndex 370 fds.push_back(ipc_channel_fd); // kBrowserFDIndex
370 fds.push_back(pid_oracle.get()); // kPIDOracleFDIndex 371 fds.push_back(pid_oracle.get()); // kPIDOracleFDIndex
371 pid = helper->Fork(process_type, fds, channel_id); 372 pid = helper->Fork(process_type, fds, channel_id);
372 373
373 // Helpers should never return in the child process. 374 // Helpers should never return in the child process.
374 CHECK_NE(pid, 0); 375 CHECK_NE(pid, 0);
375 } else { 376 } else {
376 CreatePipe(&read_pipe, &write_pipe); 377 CreatePipe(&read_pipe, &write_pipe);
377 pid = fork(); 378 // This is roughly equivalent to a fork(). We are using ForkWithFlags mainly
379 // to give it some more diverse test coverage.
380 pid = sandbox::ForkWithFlags(SIGCHLD, nullptr, nullptr);
378 } 381 }
379 382
380 if (pid == 0) { 383 if (pid == 0) {
381 // In the child process. 384 // In the child process.
382 write_pipe.reset(); 385 write_pipe.reset();
383 386
384 // Ping the PID oracle socket so the browser can find our PID. 387 // Ping the PID oracle socket so the browser can find our PID.
385 CHECK(SendZygoteChildPing(pid_oracle.get())); 388 CHECK(SendZygoteChildPing(pid_oracle.get()));
386 389
387 // Now read back our real PID from the zygote. 390 // Now read back our real PID from the zygote.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 PickleIterator iter) { 588 PickleIterator iter) {
586 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != 589 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) !=
587 sizeof(sandbox_flags_)) { 590 sizeof(sandbox_flags_)) {
588 PLOG(ERROR) << "write"; 591 PLOG(ERROR) << "write";
589 } 592 }
590 593
591 return false; 594 return false;
592 } 595 }
593 596
594 } // namespace content 597 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698