src/lib/osunix.c 1.41
1.41 2009/06/07 07:11:55 markd
make sure dumpStack does end up being recusivel called due to an error
Index: src/lib/osunix.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/osunix.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -b -B -U 4 -r1.40 -r1.41
--- src/lib/osunix.c 3 Jun 2009 00:34:11 -0000 1.40
+++ src/lib/osunix.c 7 Jun 2009 07:11:55 -0000 1.41
@@ -390,8 +390,13 @@
* prints a message, following by a new line, and then the stack track. Just
* prints errors to stderr rather than aborts. For debugging purposes
* only. */
{
+static boolean inDumpStack = FALSE; // don't allow re-entry if called from error handler
+if (inDumpStack)
+ return;
+inDumpStack = TRUE;
+
vfprintf(stderr, format, args);
fputc('\n', stderr);
fflush(stderr);
pid_t ppid = getpid();
@@ -404,25 +409,20 @@
if (pid == 0)
execPStack(ppid);
int wstat;
if (waitpid(pid, &wstat, 0) < 0)
- {
perror("waitpid on pstack failed");
- return;
- }
-if (WIFEXITED(wstat))
+else
{
- if (WEXITSTATUS(wstat) != 0)
+ if (WIFEXITED(wstat))
{
+ if (WEXITSTATUS(wstat) != 0)
fprintf(stderr, "pstack failed\n");
- return;
- }
}
-else if (WIFSIGNALED(wstat))
- {
+ else if (WIFSIGNALED(wstat))
fprintf(stderr, "pstack signaled %d\n", WTERMSIG(wstat));
- return;
}
+inDumpStack = FALSE;
}
void dumpStack(char *format, ...)
/* debugging function to run the pstack program on the current process. In