Path: utzoo!dciem!nrcaer!scs!spl1!laidbak!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!ncar!boulder!sunybcs!bingvaxu!leah!itsgw!sun.soe.clarkso From: pardo@june.cs.washington.edu (David Keppel) Newsgroups: comp.unix.wizards Subject: signal()s and stacks and trampoline code Message-ID: <5060@june.cs.washington.edu> Date: 7 Jun 88 02:50:45 GMT Article-I.D.: june.5060 Reply-To: pardo@cs.washington.edu (David Keppel) Organization: U of Washington, Computer Science, Seattle Lines: 36 Summary: I'm confused. How does this really work? [ Sorry if this has been around recently ] [ Please REPLY by mail, I will summarize ] I'm confused about signals, signal handlers, signal stacks, and trampoline code. I've been told a bunch of different things (often quite authoratatively :-) about how various versions of Un*x do it, and some of the descriptions disagree with some of the other descriptions. I'd like to know how this gets done on each of "your favorite" version of Un*x, including BSD 4.3, 4.2, SysV, SunOS, Ultrix (presumed like 4.2), Xenix, ... Here is my (mis)understanding of what happens on 4.3BSD; please don't think that I believe this to be the one true way, rather I want to know where this isn't true. + Kernel decides to deliver a signal. + The kernel pushes a few instructions, called _trampoline_code_ on to the stack. + The kernel transfers control to the trampoline code. + The trampoline code invokes the signal handler. + The call frame for the signal handler is pushed onto a seperate (seperate from the standard stack) "signal stack". + The signal hander executes. + The signal handler returns, restoring the normal sp, fp, ap, ... At the same time, the pc is set to the return point in the trampoline code. + The trampoline code traps to the kernel. + The kernel cleans the trampoline code off of the stack. This seems pretty wierd to me. Can somebody illuminate? (E-mail, please. Advance thanks!) ;-D on ( coming soon to a signal stack near you ) Pardo pardo@cs.washington.edu pardo@june.cs.washington.edu ...!{rutgers,cornell,ucsd,ubc-cs,textronix}!uw-june!pardo