c-stack.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Stack overflow handling.
  2. Copyright (C) 2002, 2004, 2008-2013 Free Software Foundation, Inc.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. /* Set up ACTION so that it is invoked on C stack overflow and on other,
  14. stack-unrelated, segmentation violation.
  15. Return -1 (setting errno) if this cannot be done.
  16. When a stack overflow or segmentation violation occurs:
  17. 1) ACTION is called. It is passed an argument equal to
  18. - 0, for a stack overflow,
  19. - SIGSEGV, for a segmentation violation that does not appear related
  20. to stack overflow.
  21. On many platforms the two cases are hard to distinguish; when in doubt,
  22. zero is passed.
  23. 2) If ACTION returns, a message is written to standard error, and the
  24. program is terminated: in the case of stack overflow, with exit code
  25. exit_failure (see "exitfail.h"), otherwise through a signal SIGSEGV.
  26. A null ACTION acts like an action that does nothing.
  27. ACTION must be async-signal-safe. ACTION together with its callees
  28. must not require more than SIGSTKSZ bytes of stack space. Also,
  29. ACTION should not call longjmp, because this implementation does
  30. not guarantee that it is safe to return to the original stack.
  31. This function may install a handler for the SIGSEGV signal or for the SIGBUS
  32. signal or exercise other system dependent exception handling APIs. */
  33. extern int c_stack_action (void (* /*action*/) (int));