Watchdog: deliver task time out SIGABRT to caller thread

Before this CL the SIGABRT coming from task timeouts was
delivered to a random thread to the process group.
This CL makes it so the signal is delivered to the same
thread that registered the task watchdog.

Bug: 120887501
Change-Id: Ibdd0fb5aab3e9e459b9c2ea7de3d256e5c4b1d3a
diff --git a/src/base/watchdog_posix.cc b/src/base/watchdog_posix.cc
index 82cd6ac..abd57d7 100644
--- a/src/base/watchdog_posix.cc
+++ b/src/base/watchdog_posix.cc
@@ -25,16 +25,19 @@
 
 #include "perfetto/base/watchdog_posix.h"
 
-#include "perfetto/base/logging.h"
-#include "perfetto/base/scoped_file.h"
-
 #include <fcntl.h>
 #include <inttypes.h>
 #include <signal.h>
 #include <stdint.h>
+
 #include <fstream>
 #include <thread>
 
+#include "perfetto/base/build_config.h"
+#include "perfetto/base/logging.h"
+#include "perfetto/base/scoped_file.h"
+#include "perfetto/base/thread_utils.h"
+
 #if PERFETTO_BUILDFLAG(PERFETTO_CHROMIUM_BUILD)
 #error perfetto::base::Watchdog should not be used in Chromium
 #endif
@@ -243,7 +246,8 @@
     return;  // No-op timer created when the watchdog is disabled.
 
   struct sigevent sev = {};
-  sev.sigev_notify = SIGEV_SIGNAL;
+  sev.sigev_notify = SIGEV_THREAD_ID;
+  sev._sigev_un._tid = base::GetThreadId();
   sev.sigev_signo = SIGABRT;
   PERFETTO_CHECK(timer_create(CLOCK_MONOTONIC, &sev, &timerid_) != -1);
   struct itimerspec its = {};