Merge "Narrow native bridge to clone_for_fork"
This commit is contained in:
commit
3b23cc7f72
1 changed files with 10 additions and 9 deletions
|
@ -33,23 +33,24 @@
|
|||
#include "private/bionic_defs.h"
|
||||
#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.
|
||||
|
|
Loading…
Reference in a new issue