Invoking a signal handler
kostikbel at gmail.com
Mon Feb 8 11:38:11 UTC 2010
On Sun, Feb 07, 2010 at 10:55:53PM -0800, Shrivats wrote:
> I am trying to understand how the kernel invokes the signal handler
for a process, to deliver an asynchronous signal posted by another
> I was looking at the sendsig() function which saves the current user
> context. My question is, when and how does the transition from the
> kernel mode to the user mode take place so that the signal handler is
The sendsig() does two things. First, it copies out the currently
saved user context to the user stack. Then, it modifies the current
context to arrange the call to the signal handler when return to
user mode is done.
After that, when the thread does usual return from the kernel to user
mode, be it return from the interrupt, or syscall, the modified context
causes execution to jump to signal trampoline code implanted to the user
mode stack by image activator. Trampoline is supplied required data by
sendsig() to call signal handler with the right arguments.
More, upon return from the signal handler, the trampoline on the
stack gets the control again, and calls sigreturn(2) syscall that
restores the old, pre-signal context saved by sendsig().
This is the model used on i386/amd64 FreeBSD, and I think that other
architectures are quite similar.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20100208/f417cace/attachment.pgp
More information about the freebsd-hackers