Skip to contentSkip to conversation

sigsetreturn (was utssys?)

parisc-linux Cary Coutant 2 participants 2 messages Aug 17, 1999

lore
Share & tools
lore
#0 lore raw
Quoted 2 lines

I also can't find a manual page for sigsetreturn() which I probably need to understand more deeply than utssys :-)

When the kernel passes control to a signal handler, it needs to set the stack up with a signal context structure and a return address that results in the restoration of that context when (and if) the signal handler returns. Since the normal BV instruction used for returns can't branch across space boundaries, the signal handler can't return directly to kernel space, so the kernel needs to supply a return address in user space that will implement the restoration of the interrupted context. This return address is the sigreturn() system call, found in libc. In order for the kernel to know the address of sigreturn, it needs to be told in advance; that's what sigsetreturn() does.

The call to sigsetreturn() has been moved around several times in the history of HP-UX. At one point, it was in the _start() routine in the C library, but that didn't get called for Fortran programs, so it was added to several of the signal routines, to make sure it got called before any signal handlers could be installed. Ultimately, I think it ended up in crt0, where it should have been all along.

Sigsetreturn() also supplies a "cookie" that the kernel can use to determine what the vintage is of the running program. For programs build for PA 1.0, for example, the cookie tells the kernel to deliver a shorter signal context record, since some of those early applications were actually dependent on the size and layout of the context record. Someone in OS land will probably have to supply you with the detailed meanings of the cookies used in this call, if it matters.

Cary Coutant
Runtime Architect

#1 lore raw
Quoted 7 lines · Cary Coutant

Since the normal BV instruction used for returns can't branch across space boundaries, the signal handler can't return directly to kernel space, so the kernel needs to supply a return address in user space that will implement the restoration of the interrupted context. This return address is the sigreturn() system call, found in libc. In order for the kernel to know the address of sigreturn, it needs to be told in advance; that's what sigsetreturn() does.

This is what Linux uses the sa_restorer in `struct sigaction' for. I think it's a better interface then sigsetreturn() so consider implementing it this way and not provide sigsetreturn.

Signature · 3 lines
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------