3

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?

0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
basin
  • 3,949
  • 2
  • 27
  • 63
  • Well, I have nothing to back this up, but I'd imagine the default handler kills them but when you provide your own handler (as it seems you have) they aren't paused or killed until and unless you do it yourself. – Kevin May 24 '12 at 16:19

1 Answers1

2

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.

R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711