Go to main content

man pages section 3: Library Interfaces and Headers

Exit Print View

Updated: Thursday, June 13, 2019

sigsegv_deinstall_handler (3)


sigsegv_deinstall_handler - stall a global SIGSEGV handler


#include <sigsegv.h>

int sigsegv_install_handler (sigsegv_handler_t handler);

void sigsegv_deinstall_handler (void);


Library Functions Manual                            sigsegv_install_handler(3)

       sigsegv_install_handler,  sigsegv_deinstall_handler - Install and dein-
       stall a global SIGSEGV handler

       #include <sigsegv.h>

       int sigsegv_install_handler (sigsegv_handler_t handler);

       void sigsegv_deinstall_handler (void);

       Pageable virtual memory is usually done in the operating system's  ker-
       nel. This library helps in implementing the others.

       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.

       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 sys-
       tem call. In this case, the program has to do what the SIGSEGV  handler
       would do, and then restart the read() operation.

       Sigsegv_install_handler  installs a global SIGSEGV handler. This should
       be called once only, and it ignores any  previously  installed  SIGSEGV

       Sigsegv_deinstall_handler  deinstalls  the global SIGSEGV handler. This
       goes back to the state where no SIGSEGV handler is installed.

       typedef int (*sigsegv_handler_t) (void* fault_address,
                                         int serious);

       Sigsegv_handler_t 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  distin-
       guish  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.

       The  handler  is run at a moment when nothing about the global state of
       the program is known. Therefore it cannot use facilities  that  manipu-
       late  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

       If success, sigsegv_install_handler returns 0,  or  -1  if  the  system
       doesn't support catching SIGSEGV.

       See attributes(7) for descriptions of the following attributes:

       |Availability   | library/libsigsegv |
       |Stability      | Uncommitted        |
       attributes(7), sigsegv(3), standards(7)

       This     software     was    built    from    source    available    at
       https://github.com/oracle/solaris-userland.   The  original   community
       source  was  downloaded  from   https://ftp.gnu.org/gnu/libsigsegv/lib-

       Further information about this software can be found on the open source
       community website at https://www.gnu.org/software/libsigsegv.

Solaris 11.4                      13 Jan 2009