Add way to ensure we are at the front of the sigaction chain
Calling this after jni_on_load fixes the unity apps. This is
not exactly correct since we may already have the following chain.
Start up:
Us -> debuggerd
After app goes in front:
App -> us -> debuggerd
After we put ourself back at the front:
Us -> app -> us -> app -> .... stack overflow.
Bug: 17620677
Change-Id: I9183997e3d5ebd51c320b5d51425be5142e938f3
(cherry picked from commit 1f24296c7c8a6501ee2388c0d20b48f471b48660)
diff --git a/sigchainlib/sigchain.h b/sigchainlib/sigchain.h
index 0de0d08..79b76a7 100644
--- a/sigchainlib/sigchain.h
+++ b/sigchainlib/sigchain.h
@@ -19,6 +19,8 @@
#include <signal.h>
+namespace art {
+
extern "C" void InitializeSignalChain();
extern "C" void ClaimSignalChain(int signal, struct sigaction* oldaction);
@@ -27,4 +29,8 @@
extern "C" void InvokeUserSignalHandler(int sig, siginfo_t* info, void* context);
+extern "C" void EnsureFrontOfChain(int signal, struct sigaction* expected_action);
+
+} // namespace art
+
#endif // ART_SIGCHAINLIB_SIGCHAIN_H_