Using sigvec & sigcontext

Hitoshi Aida aida at porthos.csl.sri.com
Tue Mar 21 06:50:40 AEST 1989


In article <331 at h.cs.wvu.wvnet.edu> dymm at b.cs.wvu.wvnet.edu (David Dymm) writes:
>So how do I use "scp"???
>
>Can I use it to explicitly restore the context to return where I
>was before the signal?

In general, no.  You should do a simulated "return from the interrupt"
to restore the context.  It includes restoring registers (including stack
pointer and program counter), switching stack (if running on sigstack) and
restoring signal mask, all in an atomic operation.  That can be done only
by returning from signal handler.  You can more or less simulate it using
assemby code, but some race condition cannot be avoidable.

>If so, then I should be able to store it somewhere for later use,
>then use it at some time in the future to go back to where I was
>before the signal occurred.  Does this make sense?

No.  The sigcontext points to a position in the stack which will no longer
available after returning from the signal handler.  You can use it
only within the signal handler.  At least you can modify the signal mask,
program couner and status register field of the sigcontext, and they will
take effect upon return from the signal handler.
--------
Hitoshi AIDA (aida at csl.sri.com)
Computer Science Laboratory, SRI International



More information about the Comp.unix.questions mailing list