title: Linux: Snoop a signal without trashing the registers for the subsequent core dump?
body: <p>When I get coredump-causing signal, I want to run my own handler to copy the siginfo_t and ucontext_t structures to global variables, so that they may be accessed in the core dump. Currently at the end of my handler I reassign the default handler and call raise(thesig). The problem with doing that is that the core dump "info registers" shows the state of the registers in my handler, and not at the time of the original signal. I realise that since I've saved ucontext_t, I can look in that for the original register values, but that knowledge is likely to get lost/forgotten when core dumps are passed around the team.</p>
  
  <p>So my question is: is there a way to reraise a signal, and ensure the core dump file holds the register state of the original signal? I thought maybe I could use some inline asm to manually restore all the regs at the end of the handler, then return to the instruction that caused the signal instead of calling raise(), but I'm not sure if we can guarantee that re-attempting the instruction will cause the same signalling behaviour as the first attempt.</p>