crash_dump: defuse our signal handlers earlier.

We have a LOG(FATAL) that can potentially happen before we turn off
SIGABRT. Move the signal handler defusing to the very start of main.

Bug: http://b/77920633
Test: treehugger
Change-Id: I7a2f2a0f2bed16e54467388044eca254102aa6a0
(cherry picked from commit 38ac45df1738496d5581b89845e48daeab7f0219)
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index a1f0211..40cf6c3 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -190,6 +190,19 @@
 static unique_fd g_tombstoned_socket;
 static unique_fd g_output_fd;
 
+static void DefuseSignalHandlers() {
+  // Don't try to dump ourselves.
+  struct sigaction action = {};
+  action.sa_handler = SIG_DFL;
+  debuggerd_register_handlers(&action);
+
+  sigset_t mask;
+  sigemptyset(&mask);
+  if (sigprocmask(SIG_SETMASK, &mask, nullptr) != 0) {
+    PLOG(FATAL) << "failed to set signal mask";
+  }
+}
+
 static void Initialize(char** argv) {
   android::base::InitLogging(argv);
   android::base::SetAborter([](const char* abort_msg) {
@@ -213,17 +226,6 @@
 
     _exit(1);
   });
-
-  // Don't try to dump ourselves.
-  struct sigaction action = {};
-  action.sa_handler = SIG_DFL;
-  debuggerd_register_handlers(&action);
-
-  sigset_t mask;
-  sigemptyset(&mask);
-  if (sigprocmask(SIG_SETMASK, &mask, nullptr) != 0) {
-    PLOG(FATAL) << "failed to set signal mask";
-  }
 }
 
 static void ParseArgs(int argc, char** argv, pid_t* pseudothread_tid, DebuggerdDumpType* dump_type) {
@@ -321,6 +323,8 @@
 }
 
 int main(int argc, char** argv) {
+  DefuseSignalHandlers();
+
   atrace_begin(ATRACE_TAG, "before reparent");
   pid_t target_process = getppid();