Unregister profiling signal handler in children.
Otherwise, we could end up with the forked child being the target of
another profile.
Change-Id: I63b4d5d7a0d34e1153bf0ae5bf0c4d7698656d32
diff --git a/perfetto_hprof/perfetto_hprof.cc b/perfetto_hprof/perfetto_hprof.cc
index fcaa8e6..b4b8d22 100644
--- a/perfetto_hprof/perfetto_hprof.cc
+++ b/perfetto_hprof/perfetto_hprof.cc
@@ -595,7 +595,15 @@
}
// The following code is only executed by the child of the original process.
- //
+
+ // Uninstall signal handler, so we don't trigger a profile on it.
+ if (sigaction(kJavaHeapprofdSignal, &g_orig_act, nullptr) != 0) {
+ close(g_signal_pipe_fds[0]);
+ close(g_signal_pipe_fds[1]);
+ PLOG(FATAL) << "Failed to sigaction";
+ return;
+ }
+
// Daemon creates a new process that is the grand-child of the original process, and exits.
if (daemon(0, 0) == -1) {
PLOG(FATAL) << "daemon";