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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process/launch.h ('k') | base/process/launch_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/launch_mac.cc
diff --git a/base/process/launch_mac.cc b/base/process/launch_mac.cc
index 176edca72ea7b8b5db4ceab0531b811554a03fa3..ce02475541e06028a500d34d1448764428215c79 100644
--- a/base/process/launch_mac.cc
+++ b/base/process/launch_mac.cc
@@ -5,6 +5,9 @@
#include "base/process/launch.h"
#include <mach/mach.h>
+#include <servers/bootstrap.h>
+
+#include "base/logging.h"
namespace base {
@@ -25,4 +28,21 @@ void RestoreDefaultExceptionHandler() {
EXCEPTION_DEFAULT, THREAD_STATE_NONE);
}
+void ReplaceBootstrapPort(const std::string& new_bootstrap_name) {
+ // This function is called between fork() and exec(), so it should take care
+ // to run properly in that situation.
+
+ mach_port_t port = MACH_PORT_NULL;
+ kern_return_t kr = bootstrap_look_up(bootstrap_port,
+ new_bootstrap_name.c_str(), &port);
+ if (kr != KERN_SUCCESS) {
+ RAW_LOG(FATAL, "Failed to look up replacement bootstrap port.");
+ }
+
+ kr = task_set_bootstrap_port(mach_task_self(), port);
+ if (kr != KERN_SUCCESS) {
+ RAW_LOG(FATAL, "Failed to replace bootstrap port.");
+ }
+}
+
} // namespace base
« 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