From 06053405e9ee4c62e687d3cc49e4c8814632670f Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 29 Feb 2024 22:59:20 +0000 Subject: [PATCH] Use _Fork(). POSIX issue 8 has a standard way to avoid pthread_atfork() handlers. Change-Id: I801c55dc3fb9e14cc03f854992d60872c5468ab5 --- debuggerd/handler/debuggerd_handler.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp index 141723b03..595f37388 100644 --- a/debuggerd/handler/debuggerd_handler.cpp +++ b/debuggerd/handler/debuggerd_handler.cpp @@ -275,10 +275,6 @@ static void raise_caps() { } } -static pid_t __fork() { - return clone(nullptr, nullptr, 0, nullptr); -} - // Double-clone, with CLONE_FILES to share the file descriptor table for kcmp validation. // Returns 0 in the orphaned child, the pid of the orphan in the original process, or -1 on failure. static void create_vm_process() { @@ -426,7 +422,7 @@ static int debuggerd_dispatch_pseudothread(void* arg) { } // Don't use fork(2) to avoid calling pthread_atfork handlers. - pid_t crash_dump_pid = __fork(); + pid_t crash_dump_pid = _Fork(); if (crash_dump_pid == -1) { async_safe_format_log(ANDROID_LOG_FATAL, "libc", "failed to fork in debuggerd signal handler: %s", strerror(errno));