Date: Fri, 9 Jul 1999 00:06:40 -0400 (EDT) From: "John W. DeBoskey" <jwd@unx.sas.com> To: freebsd-hackers@freebsd.org Subject: sigaction inconsistancy (here I go again) Message-ID: <199907090406.AAA10435@bb01f39.unx.sas.com>
next in thread | raw e-mail | index | archive | help
Hi, Running -current... I'm trying to verify SIGFPE handling and am finding some interesting issues. In the following test program, a divide by zero is done and the SIGFPE delivered. $ ./fp sig == 8 code== 0 z has the value 1.000000 It seems that from <machine/trap.h> the value of code should have been: /* codes for SIGFPE/ARITHTRAP */ #define FPE_FLTDIV_TRAP 0x3 /* floating/decimal divide by zero */ ie: 3 and not 0. Also, I haven't gone into the code yet, but the floating point registers are not saved into the sigcontext so that they can be inspected and modified as appropriate. Thanks, John ps: I also noted that SA_RESTART is not documented in the man page with the other mask bits, but instead is mentioned in a follow-on statement. Just slightly misleading. -------------------------------------------------------------------------- #include <stdio.h> #include <floatingpoint.h> #include <signal.h> void fphand(int sig, int code, struct sigcontext *scp) { fprintf(stderr,"sig == %d\n",sig); fprintf(stderr,"code== %d\n",code); return; } void setup() { int rc; struct sigaction act, oact; act.sa_handler = &fphand; act.sa_mask = 0; act.sa_flags = SA_RESTART; /* not doc'd in man page */ rc = sigaction(SIGFPE, &act, &oact); if (rc) { perror("sigaction"); exit(1); } return; } double doit(double x, double y) { return(x / y); } int main() { double x,y,z; fp_except_t mask = FP_X_DZ; setup(); fpsetmask(mask); x = 1.0; y = 0.0; z = doit(x,y); printf("z has the value %f\n",z); return((int) z); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199907090406.AAA10435>