home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18668 < prev    next >
Encoding:
Text File  |  1992-12-21  |  1.1 KB  |  54 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!caen!mslyz
  3. From: mslyz@congeries.engin.umich.edu (Marko J Slyz )
  4. Subject: signal.h help
  5. Message-ID: <#fV=v+B@engin.umich.edu>
  6. Date: Sat, 19 Dec 92 01:47:56 EST
  7. Organization: University of Michigan Engineering, Ann Arbor
  8. Originator: mslyz@congeries.engin.umich.edu
  9. Nntp-Posting-Host: congeries.engin.umich.edu
  10. Lines: 42
  11.  
  12.  
  13. The following program was written for an HP9000/700 and compiled
  14. with:  c89 -ot1 t1.c -lm
  15.  
  16. It compiles with no errors or warnings.
  17. -----------------------------------------------------
  18. #include <stdio.h>
  19. #include <signal.h>
  20.  
  21. extern int errno;
  22.  
  23. main()
  24. {
  25.   double x,y;
  26.  
  27.   y = 0.0;  /* sic */
  28.  
  29.  if (signal(SIGFPE,SIG_IGN) == SIG_ERR)
  30.     printf("couldn't set up new signal handler\n");
  31.  
  32.   x = 100.0/y;
  33.  
  34.   printf("x = %.15g\n", x);
  35.   printf("(char)x = %d\n",(char)x);
  36. }
  37.  
  38. -----------------------------------------------------
  39.  
  40. When run as shown above it prints
  41. x = ++
  42.  
  43. and then hangs. ^C will recover (but not just a CR). If you
  44. leave out the "if" statement it says
  45.  
  46. x = ++
  47. Floating exception (core dumped)
  48.  
  49. I've tried writing my own error handler and that doesn't help.
  50. Any ideas?
  51.  
  52. Thanks in advance,
  53. Marko
  54.