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?
No, a handled SIGSEGV
does not affect any other threads (although if it resulted from memory corruption or other UB, that UB could of course affect other threads). An unhandled SIGSEGV
on the other hand terminates the whole process.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.