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

Side by Side Diff: base/process/launch_mac.cc

Issue 347783002: Alter the design of the bootstrap sandbox to only take over the bootstrap port of children when nec… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « base/process/launch.h ('k') | base/process/launch_posix.cc » ('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 "base/process/launch.h" 5 #include "base/process/launch.h"
6 6
7 #include <mach/mach.h> 7 #include <mach/mach.h>
8 #include <servers/bootstrap.h>
9
10 #include "base/logging.h"
8 11
9 namespace base { 12 namespace base {
10 13
11 void RestoreDefaultExceptionHandler() { 14 void RestoreDefaultExceptionHandler() {
12 // This function is tailored to remove the Breakpad exception handler. 15 // This function is tailored to remove the Breakpad exception handler.
13 // exception_mask matches s_exception_mask in 16 // exception_mask matches s_exception_mask in
14 // breakpad/src/client/mac/handler/exception_handler.cc 17 // breakpad/src/client/mac/handler/exception_handler.cc
15 const exception_mask_t exception_mask = EXC_MASK_BAD_ACCESS | 18 const exception_mask_t exception_mask = EXC_MASK_BAD_ACCESS |
16 EXC_MASK_BAD_INSTRUCTION | 19 EXC_MASK_BAD_INSTRUCTION |
17 EXC_MASK_ARITHMETIC | 20 EXC_MASK_ARITHMETIC |
18 EXC_MASK_BREAKPOINT; 21 EXC_MASK_BREAKPOINT;
19 22
20 // Setting the exception port to MACH_PORT_NULL may not be entirely 23 // Setting the exception port to MACH_PORT_NULL may not be entirely
21 // kosher to restore the default exception handler, but in practice, 24 // kosher to restore the default exception handler, but in practice,
22 // it results in the exception port being set to Apple Crash Reporter, 25 // it results in the exception port being set to Apple Crash Reporter,
23 // the desired behavior. 26 // the desired behavior.
24 task_set_exception_ports(mach_task_self(), exception_mask, MACH_PORT_NULL, 27 task_set_exception_ports(mach_task_self(), exception_mask, MACH_PORT_NULL,
25 EXCEPTION_DEFAULT, THREAD_STATE_NONE); 28 EXCEPTION_DEFAULT, THREAD_STATE_NONE);
26 } 29 }
27 30
31 void ReplaceBootstrapPort(const std::string& new_bootstrap_name) {
32 // This function is called between fork() and exec(), so it should take care
33 // to run properly in that situation.
34
35 mach_port_t port = MACH_PORT_NULL;
36 kern_return_t kr = bootstrap_look_up(bootstrap_port,
37 new_bootstrap_name.c_str(), &port);
38 if (kr != KERN_SUCCESS) {
39 RAW_LOG(FATAL, "Failed to look up replacement bootstrap port.");
40 }
41
42 kr = task_set_bootstrap_port(mach_task_self(), port);
43 if (kr != KERN_SUCCESS) {
44 RAW_LOG(FATAL, "Failed to replace bootstrap port.");
45 }
46 }
47
28 } // namespace base 48 } // namespace base
OLDNEW
« no previous file with comments | « base/process/launch.h ('k') | base/process/launch_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698