 +{
 +    tcs_t *tcs = NULL;
 +    {
-+        std::lock_guard<std::mutex> lock(thread_to_tcs_lock);
-+        auto it = thread_to_tcs.find(pthread_self());
-+        if (it != thread_to_tcs.end())
++        std::lock_guard<std::mutex> lock(*thread_to_tcs_lock);
++        auto it = thread_to_tcs->find(pthread_self());
++        if (it != thread_to_tcs->end())
 +        {
 +            tcs = it->second;
 +            tcs_sim_t *tcs_sim = reinterpret_cast<tcs_sim_t *>(tcs->reserved);

 uintptr_t _EINIT(secs_t* secs, enclave_css_t *css, token_t *launch)
 {
     CEnclaveMngr *mngr = CEnclaveMngr::get_instance();
@@ -129,6 +249,8 @@
         }
     }
 

+
+    // Invoke the registered signal handler.
+    {
+        std::lock_guard<std::mutex> lock(*registered_signal_handlers_lock);
+        const auto it = registered_signal_handlers->find(signum);
+        if (it != registered_signal_handlers->end())
+        {
+            struct sigaction *act = it->second.get();
+            if ((!(act->sa_flags & SA_SIGINFO)) && act->sa_handler)
