divzero.c 415 B

1234567891011121314151617181920
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <signal.h>
  6. void handler (int signal)
  7. {
  8. printf("get signal: %d\n", signal);
  9. exit(0);
  10. }
  11. int main (void)
  12. {
  13. int i = 0;
  14. signal(SIGFPE, &handler);
  15. i = 1 / i;
  16. return 0;
  17. }