'\" te .\" .\" .\" Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. .\" .\" .TH sigsegv_install_handler 3 "13 Jan 2009" "SunOS 5.11" .SH NAME sigsegv_install_handler, sigsegv_deinstall_handler - Install and deinstall a global SIGSEGV handler .sp .SH SYNOPSIS .sp #include <\fBsigsegv.h\fR> .sp int \fBsigsegv_install_handler\fR (\fIsigsegv_handler_t handler\fR); .sp void \fBsigsegv_deinstall_handler\fR (\fIvoid\fR); .sp .SH DESCRIPTION .sp .LP Pageable virtual memory is usually done in the operating system's kernel. This library helps in implementing the others. .sp .LP Installing a page fault handler is usually more efficient than doing access checks in software at every access, because it's effectively the hardware (the MMU) which checks whether a page is present or not. .sp .LP Note that if you use system calls (like read()) to write into write-protected pages, the system will react by returning -1 and setting errno to EFAULT, instead of signalling SIGSEGV and restarting the system call. In this case, the program has to do what the SIGSEGV handler would do, and then restart the read() operation. .sp .LP \fBSigsegv_install_handler\fR installs a global SIGSEGV handler. This should be called once only, and it ignores any previously installed SIGSEGV handler. .sp .LP \fBSigsegv_deinstall_handler\fR deinstalls the global SIGSEGV handler. This goes back to the state where no SIGSEGV handler is installed. .sp .SH OPERANDS .sp .LP typedef int (*\fBsigsegv_handler_t\fR) (\fIvoid* fault_address\fR, .RS +34 \fIint serious\fR); .RE .sp \fISigsegv_handler_t\fR is the type of a global SIGSEGV handler.The fault address is passed as argument. The access type (read access or write access) is not passed; your handler has to know itself how to distinguish these two cases. The second argument is 0, meaning it could also be a stack overflow, or 1, meaning the handler should seriously try to fix the fault. The return value should be nonzero if the handler has done its job and no other handler should be called, or 0 if the handler declines responsibility for the given address. .sp .LP The handler is run at a moment when nothing about the global state of the program is known. Therefore it cannot use facilities that manipulate global variables or locks. In particular, it cannot use malloc(); use mmap() instead. It cannot use fopen(); use open() instead. Etc. All global variables that are accessed by the handler should be marked 'volatile'. .sp .SH EXIT STATUS .sp .LP If success, sigsegv_install_handler returns 0, or -1 if the system doesn't support catching SIGSEGV. .sp .\" Oracle has added the ARC stability level to this manual page .SH ATTRIBUTES See .BR attributes (5) for descriptions of the following attributes: .sp .TS box; cbp-1 | cbp-1 l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE = Availability library/libsigsegv = Stability Uncommitted .TE .PP .SH SEE ALSO .sp .LP \fBattributes\fR(5), \fBsigsegv\fR(3), \fBstandards\fR(5) .SH NOTES .\" Oracle has added source availability information to this manual page This software was built from source available at https://java.net/projects/solaris-userland. The original community source was downloaded from http://ftp.gnu.org/gnu/libsigsegv/libsigsegv-2.6.tar.gz Further information about this software can be found on the open source community website at http://www.gnu.org/software/libsigsegv/.