Xref: utzoo comp.unix.questions:12429 comp.unix.wizards:15210 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!kth!enea!dkuug!freja!skinfaxe!seindal From: seindal@skinfaxe.diku.dk (Rene' Seindal) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: Using sigvec & sigcontext Message-ID: <4549@freja.diku.dk> Date: 23 Mar 89 16:26:33 GMT References: <331@h.cs.wvu.wvnet.edu> Sender: news@freja.diku.dk Lines: 38 dymm@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@diku.dk).