Using sigvec & sigcontext

Rene' Seindal seindal at skinfaxe.diku.dk
Fri Mar 24 02:26:33 AEST 1989


dymm at b.cs.wvu.wvnet.edu (David Dymm) writes:
> A quick question concerning "sigvec".

> The UNIX manual shows the user's interrupt handler as:

>     handler (sig, code, scp)
> 	int sig, code;
> 	struct sigcontext *scp;

> According to the manual:
> "Scp is a pointer to the sigcontext structure used to restore
> the context from before the signal."

> So how do I use "scp"???

First of all, sigvec(2) and struct sigcontext can only be expected to exist in
4.3BSD or 4.2BSD derived systems.

4.3BSD from Berkeley (or Mt. Xinu) has a sigreturn(2) systemcall, which allows
you to return from a signal handler, using a specified sigcontext.  It could
probably be used to implement coroutine-like features.

On 4.3BSD on Vaxen, the struct sigcontext has the same contents as a
``jmp_buf'' (??), so on such a system you can call sigreturn with a jmp_buf
(made with setjmp(3)) og call longjmp(3) with a sigcontext (as passed to a
signal handler).  This is undocumented and implementation-defined, so you
probably wouldn't want to use it.

Even more amusing, the is an undocumented system call (no. 139) in at least
4.3 (and 4.2) from Berkeley, Ultrix 2.0, and SunOS 3.X (and 4.0, according to
adb.  I haven't tried), which is used by longjmp(3) to restore the saved
context.  It takes a jmp_buf/struct sigcontext as the sole argument.  It is a
kind of simplified sigreturn(2).  Don't look in sysent for it, since it will
probably not be there.

I guess the conclusion to all this is that you don't use scp.

Rene' Seindal (seindal at diku.dk).



More information about the Comp.unix.questions mailing list