static void sig_handler(int sig, siginfo_t *info, void *p) { int idx; idx = get_tsd(thread_id); LM_INFO("Thread %d received signal %d\n", idx, sig); if ( idx==0 ) { /* attendent thread received dealy signall */ /* before allowing a coredump, check id there are any other threads waiting to dump a core */ resume_threads_coredumping(); /* if still alive, we proceed with core dumping */ } else if ( !rt_coredump ) { LM_INFO("no rt coredump -> sending signal SIGTERM to proccess\n"); tt[idx].core_dump = PT_CORE_WAITING; /* Send SIGTERM to attendent */ kill(getpid(), SIGTERM); /* waiting for cleanup */ while (tt[idx].core_dump != PT_CORE_ALLOWED) usleep(10); /*proceed with the core dumping */ } /* Put back old sigaction to get a core dump */ if (sigaction(SIGSEGV, &old_sigsegv_hdl, NULL) < 0) { LM_ERR("failed to reset old sigaction"); return ; } }
/* You can *only* call this when either: * - you have called MPII_Get_global_init() at least once * - there is only one thread that could possibly call it at once */ void *MPII_Get_global (Key **key, int size, void *init) { void *ptr; if (*key == (Key *) 0) { int mpi_init; MPI_Initialized (&mpi_init); if (mpi_init) { if (!initialized) { new_mutex (mutex); initialized++; } lock (mutex); } if (*key == (Key *) 0) /* still */ { *key = (Key *) malloc (sizeof (Key)); new_tsd (**key); } if (mpi_init) unlock (mutex); } ptr = get_tsd (**key); if (ptr == (void *) 0) { ptr = (void *) malloc (size); if (ptr == (void *) 0) { perror ("g2tsd: MPII_Get_global: malloc failed"); exit (1); } memcpy (ptr, init, size); set_tsd (**key, ptr); } return ptr; }
PUBLIC int MPI_Initialized (long int *flag) { MPII_Initialized_init (); *flag = (long int) get_tsd(MPII_init_key); return MPI_SUCCESS; }