12.07.2015 Views

INTRO (9) NetBSD Kernel Developer's Manual INTRO (9) NAME ...

INTRO (9) NetBSD Kernel Developer's Manual INTRO (9) NAME ...

INTRO (9) NetBSD Kernel Developer's Manual INTRO (9) NAME ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SIGNAL (9) <strong>NetBSD</strong> <strong>Kernel</strong> Developer’s <strong>Manual</strong> SIGNAL (9)void killproc(struct proc ∗p , const char ∗why)This function sends a SIGKILL signal to the specified process. The message provided by why issent to the system log and is also displayed on the process’s controlling terminal.void sigexit(struct proc ∗p , int signum)This function forces the process p to exit with the signal signum, generating a core file if appropriate.No checks are made for masked or caught signals; the process always exits.int sigmasked(struct proc ∗p , int signum)This function returns non-zero if the signal specified by signum is ignored or masked for processp.void sendsig(const ksiginfo_t ∗ks , const sigset_t ∗mask)This function is provided by machine-dependent code, and is used to invoke a signal handler for thecurrent process. sendsig() must prepare the registers and stack of the current process to invokethe signal handler stored in the process’s struct sigacts. This may include switching to analternate signal stack specified by the process. The previous register, stack, and signal state arestored in a ucontext_t, which is then copied out to the user’s stack.The registers and stack must be set up to invoke the signal handler as follows:(∗handler)(int signum, siginfo_t ∗info, void ∗ctx)where signum is the signal number, info contains additional signal specific information whenSA_SIGINFO is specified when setting up the signal handler. ctx is the pointer to ucontext_ton the user’s stack. The registers and stack must also arrange for the signal handler to return to thesignal trampoline. The trampoline is then used to return to the code which was executing when thesignal was delivered using the setcontext(2) system call.For performance reasons, it is recommended that sendsig() arrange for the signal handler to beinvoked directly on architectures where it is convenient to do so. In this case, the trampoline is usedonly for the signal return path. If it is not feasible to directly invoke the signal handler, the trampolineis also used to invoke the handler, performing any final set up that was not possible forsendsig() to perform.sendsig() must invoke the signal trampoline with the correct ABI. The ABI of the signal trampolineis specified on a per-signal basis in the sigacts() structure for the process. Trampoline version0 is reserved for the legacy kernel-provided, on-stack signal trampoline. All other trampolineversions indicate a specific trampoline ABI. This ABI is coordinated with machine-dependent codein the system C library.SIGNAL TRAMPOLINEThe signal trampoline is a special piece of code which provides support for invoking the signal handlers for aprocess. The trampoline is used to return from the signal handler back to the code which was executingwhen the signal was delivered, and is also used to invoke the handler itself on architectures where it is notfeasible to have the kernel invoke the handler directly.In traditional UNIX systems, the signal trampoline, also referred to as the “sigcode”, is provided by the kerneland copied to the top of the user’s stack when a new process is created or a new program image is exec’d.Starting in <strong>NetBSD</strong> 2.0, the signal trampoline is provided by the system C library. This allows for more flexibilitywhen the signal facility is extended, makes dealing with signals easier in debuggers, such as gdb(1),and may also enhance system security by allowing the kernel to disallow execution of code on the stack.<strong>NetBSD</strong> 3.0 December 20, 2005 5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!