abort.c 710 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* # abort
  2. *
  3. * Raise a SIGABRT, an ANSI C signal which by default kills the program.
  4. *
  5. * ....
  6. * man abort
  7. * ....
  8. *
  9. * Bibliography:
  10. *
  11. * * http://stackoverflow.com/questions/397075/what-is-the-difference-between-exit-and-abort
  12. * * http://stackoverflow.com/questions/3676221/when-abort-is-preferred-over-exit
  13. *
  14. * Differences from exit: does not run regular program teardown:
  15. *
  16. * * does not call `atexit` function.
  17. * * does not call C++ destructors
  18. *
  19. * `assert()` exits the program with abort.
  20. */
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23. void atexit_func() {
  24. puts("atexit");
  25. }
  26. int main(void) {
  27. /* Will not get called. */
  28. atexit(atexit_func);
  29. abort();
  30. return EXIT_SUCCESS;
  31. }