13 #include <sys/types.h>
34 if (pipe(pipefd) != 0) {
43 }
else if (kidpid == 0) {
49 dup2(pipefd[1],STDOUT_FILENO);
50 dup2(pipefd[1],STDERR_FILENO);
52 snprintf(parent,
sizeof(parent),
"%d", getppid());
58 execle(
"/usr/bin/pstack",
"pstack", parent, NULL, NULL);
59 execle(
"/usr/bin/eu-stack",
"eu-stack",
"-p", parent, NULL, NULL);
61 sprintf(buf,
"No tools to pretty print a stack trace for pid %d.\n"
62 "Fallback to glibc backtrace which may not contain all symbols.\n "
63 "run eu-addr2line to pretty print the output.\n", getppid());
65 write(STDOUT_FILENO, buf, strlen(buf));
77 bytesread = read(pipefd[0], btline,
sizeof(btline) - 1);
80 btline[bytesread] = 0;
81 write(STDOUT_FILENO, btline, strlen(btline));
83 else if ((bytesread < 0) ||
84 ((errno != EINTR) && (errno != EAGAIN)))
89 waitpid(kidpid, &kidstat, 0);
91 if (WIFEXITED(kidstat) && (WEXITSTATUS(kidstat) == EXIT_FAILURE)) {
93 backtrace_symbols_fd(buf, 100, STDOUT_FILENO);
105 const char btline[] =
"Killed by Signal %d\n";
107 sprintf(buf, btline, no);
108 write(STDOUT_FILENO, buf, strlen(buf));
111 MPI_Abort(MPI_COMM_WORLD, no);
117 struct sigaction act, oact;
119 int siglist[] = { SIGSEGV, SIGQUIT, SIGILL, SIGFPE, SIGBUS, 0};
120 sigemptyset(&act.sa_mask);
126 for(i = 0; siglist[i] != 0; i ++) {
127 sigaction(siglist[i], &act, &oact);
155 MPI_Comm_rank(MPI_COMM_WORLD, &
ThisTask);
159 MPI_Abort(MPI_COMM_WORLD, where);
175 void message(
int where,
const char * fmt, ...)
static void init_stacktrace(void)
static int show_backtrace(void)
void message(int where, const char *fmt,...)
void init_endrun(int backtrace)
static void OsSigHandler(int no)
void endrun(int where, const char *fmt,...)
void MPIU_Tracev(MPI_Comm comm, int where, int error, const char *fmt, va_list va)