I develop a program on Solaris 10. I want it to print stack trace on crash. I found this example:
static void pstack()
{
char buf[256];
sprintf(buf, "/usr/proc/bin/pstack %d |/bin/tee traceback.txt\n", (int)getpid());
/* undefine LD_PRELOAD to avoid 64-bit problems */
(void)putenv("LD_PRELOAD=");
system(buf);
}
void sighanterm(int signo, siginfo_t *info, void *context) {
...
pstack();
}
The interesting thing is: while /usr/proc/bin/pstack
executes, other threads keep printing their output too.
Do the threads resume when the system()
is called or they don't stop at all?
Can I stop them explicitly in the handler?