Home > Net >  Returning from a signal handler via setcontext
Returning from a signal handler via setcontext

Time:09-21

I'm trying to use the third argument of a SA_SIGINFO sigaction to jump to the interrupted context directly.

Thought this:

void action(int Sig, siginfo_t *Info, void *Uctx) { 
    ucontext_t *uc = Uctx; setcontext(uc); 
}

would have the same effect as just:

void action(int Sig, siginfo_t *Info, void *Uctx) { 
    return; 
}

but curiously it accepts three signals (that invoke the setcontext-calling handler), and then it segfaults in setcontext:

Dump of assembler code for function setcontext:
   0x00007ffff7a34180 < 0>:     push   %rdi
   0x00007ffff7a34181 < 1>:     lea    0x128(%rdi),%rsi
   0x00007ffff7a34188 < 8>:     xor               
  • Related