Message-Id: <199602291105.GAA27188@delorie.com> From: Emmanuel Bigler Subject: a test program to trap floating exceptions w DJGPP v.2. To: djgpp AT delorie DOT com Date: Thu, 29 Feb 1996 12:09:22 +0100 (MET) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Length: 1842 I'm trying to use the signal() routine of DJGPP v.2 to trap floating point exceptions, and until now I have not been sucessful getting a prog that does not hang the machine. Apparently, the exception routine is never reached. But I am not sure I'm using the signal() properly since I'm more a FORTRAN guy, however I tested the same prog under a true UNIX (HPUX), and there div by 0 and log(0) are handled separetely, whereas raise(SIGFPE) correctly goes to the routine exception. This is a short summary/prog and what happens -Emmanuel Emmanuel BIGLER courrier electronique bigler AT alpha DOT univ-fcomte DOT fr e-mail telephone E.B. +33 81 66 69 54 E.B. phone secretariat LPMO +33 81 66 69 99 LPMO secretary telecopie +33 81 66 69 98 fax Laboratoire de Physique et Metrologie des Oscillateurs LPMO/CNRS, 32, avenue de l'observatoire 25044 Besancon Cedex, FRANCE -------------------------------------------------- # exceptions and signal test program t.c # for DJGPP v. 2 / DOS (gcc 2.7.2) # compiled without optimization : # gcc -s -o t t.c -lm # #include #include #include void exception(int j) { printf("exception..!") ; exit(); } double one=1, zero=0; main() { double res; /*signal(SIGFPE, exception);*/ /* this line hangs ; hard reboot requested*/ signal(SIGFPE, SIG_IGN); /* this one also (nope..) */ /* raise(SIGFPE); */ /* this one *alone* works and exits even if there is no signal call before ; with a signal call before, the prog hangs and never reaches this line */ res = one/zero; res = log(zero); return res=-1.0; }