I am developing a program on Solaris 10. I want it to print a stack trace on failure. I found this example:
static void pstack()
{
char buf[256];
sprintf(buf, "/usr/proc/bin/pstack %d |/bin/tee traceback.txt\n", (int)getpid());
(void)putenv("LD_PRELOAD=");
system(buf);
}
void sighanterm(int signo, siginfo_t *info, void *context) {
...
pstack();
}
Interestingly, while /usr/proc/bin/pstackexecuted, other threads also print their output. Do threads repeat on a call system()or do they not stop at all? Can I stop them explicitly in the handler?
basin source
share