aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLev Rumyantsev <levarum@google.com>2020-06-09 21:11:03 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-06-09 21:11:03 +0000
commit55650b620f98862ad87056ac8c6a5329b8f00ee9 (patch)
tree2229c51ec884e834cb6c30b516c81bbadc771a92
parent716bb29549fa1d17b206bcc6016fecdda2f090a6 (diff)
parent589927296be77bcd0baf3237cb0c89d4f5272fba (diff)
downloadbionic-55650b620f98862ad87056ac8c6a5329b8f00ee9.tar.gz
Narrow native bridge to clone_for_fork am: 018f4a1310 am: 589927296b
Original change: https://googleplex-android-review.googlesource.com/c/platform/bionic/+/11800684 Change-Id: I81c54a1a5b693b107c639579772510a857418de9
-rw-r--r--libc/bionic/fork.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/libc/bionic/fork.cpp b/libc/bionic/fork.cpp
index cda5e8533..c9a1ca839 100644
--- a/libc/bionic/fork.cpp
+++ b/libc/bionic/fork.cpp
@@ -34,22 +34,23 @@
#include "pthread_internal.h"
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
+int __clone_for_fork() {
+ pthread_internal_t* self = __get_thread();
+
+ return clone(nullptr, nullptr, (CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD), nullptr,
+ nullptr, nullptr, &(self->tid));
+}
+
+__BIONIC_WEAK_FOR_NATIVE_BRIDGE
int fork() {
__bionic_atfork_run_prepare();
- pthread_internal_t* self = __get_thread();
+ int result = __clone_for_fork();
- int result = clone(nullptr,
- nullptr,
- (CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD),
- nullptr,
- nullptr,
- nullptr,
- &(self->tid));
if (result == 0) {
// Update the cached pid, since clone() will not set it directly (as
// self->tid is updated by the kernel).
- self->set_cached_pid(gettid());
+ __get_thread()->set_cached_pid(gettid());
// Disable fdsan post-fork, so we don't falsely trigger on processes that
// fork, close all of their fds blindly, and then exec.