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

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

Issue 831373002: Move ForkWithFlags from sandbox/ to base/ and plug it into LaunchProcess. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments. Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « base/process/process_util_unittest.cc ('k') | sandbox/linux/services/syscall_wrappers.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) 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 fds.push_back(ipc_channel_fd); // kBrowserFDIndex 367 fds.push_back(ipc_channel_fd); // kBrowserFDIndex
368 fds.push_back(pid_oracle.get()); // kPIDOracleFDIndex 368 fds.push_back(pid_oracle.get()); // kPIDOracleFDIndex
369 pid = helper->Fork(process_type, fds, channel_id); 369 pid = helper->Fork(process_type, fds, channel_id);
370 370
371 // Helpers should never return in the child process. 371 // Helpers should never return in the child process.
372 CHECK_NE(pid, 0); 372 CHECK_NE(pid, 0);
373 } else { 373 } else {
374 CreatePipe(&read_pipe, &write_pipe); 374 CreatePipe(&read_pipe, &write_pipe);
375 // This is roughly equivalent to a fork(). We are using ForkWithFlags mainly 375 // This is roughly equivalent to a fork(). We are using ForkWithFlags mainly
376 // to give it some more diverse test coverage. 376 // to give it some more diverse test coverage.
377 pid = sandbox::ForkWithFlags(SIGCHLD, nullptr, nullptr); 377 pid = base::ForkWithFlags(SIGCHLD, nullptr, nullptr);
378 } 378 }
379 379
380 if (pid == 0) { 380 if (pid == 0) {
381 // In the child process. 381 // In the child process.
382 write_pipe.reset(); 382 write_pipe.reset();
383 383
384 // Ping the PID oracle socket so the browser can find our PID. 384 // Ping the PID oracle socket so the browser can find our PID.
385 CHECK(SendZygoteChildPing(pid_oracle.get())); 385 CHECK(SendZygoteChildPing(pid_oracle.get()));
386 386
387 // Now read back our real PID from the zygote. 387 // Now read back our real PID from the zygote.
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 PickleIterator iter) { 582 PickleIterator iter) {
583 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != 583 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) !=
584 sizeof(sandbox_flags_)) { 584 sizeof(sandbox_flags_)) {
585 PLOG(ERROR) << "write"; 585 PLOG(ERROR) << "write";
586 } 586 }
587 587
588 return false; 588 return false;
589 } 589 }
590 590
591 } // namespace content 591 } // namespace content
OLDNEW
« no previous file with comments | « base/process/process_util_unittest.cc ('k') | sandbox/linux/services/syscall_wrappers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698