Chapter Contents |
Previous |
Next |
SIGFPE |
Default handling | |
Ignoring the signal | |
Information returned by siginfo | |
Notes on defining a handler | |
USS Considerations |
SIGFPE
signal is raised when a computational error occurs. These errors
include floating-point overflow, floating-point underflow, and either integer-
or floating-point division by 0. Note that integer overflow never causes
a signal; when integer overflow occurs, the result is reduced to 32 bits by
discarding the most significant bits and is then interpreted as a signed integer.
Default handling |
The default handling for
SIGFPE
is to raise a more specific signal for the
SIGFPOFL
,
SIGFPUFL
,
SIGFPDIV
, or
SIGIDIV
conditions.
Handling of the more specific signal depends on whether a handler has been
defined for it. Refer to the descriptions of each of these signals for more
details.
Ignoring the signal |
If your program ignores
SIGFPE
, the result of the computation that raises
SIGFPE
is undefined, unless the computation causes an
underflow. For
underflows, the result is set to 0.
Information returned by siginfo |
If you call
siginfo
after a
SIGFPE
signal occurs,
siginfo
returns a pointer to a structure of type
FPE_t
. This structure is
defined as:
typedef struct { int int_code; /* interrupt code */ union { int *intv; /* result for integer expression */ double *doublev; /* result for double expression */ } result; char *EPIE; /* pointer to hardware program check info */ double *fpregs; /* floating-point register contents */ } FPE_t;
The
int_code
field
contains the number of the more specific signal associated with the
SIGFPOFL
,
SIGFPUFL
,
SIGFPDIV
, or
SIGIDIV
conditions. The
result
field is a pointer to the result of the computation that raises the signal.
If you want to continue processing, you can change the value that
result
points to.
The
EPIE
field is
a pointer to a control block containing hardware information available at
the time the signal occurs. (This information includes program status word
and registers.) For information on the EPIE format, see IBM publication MVS/XA Supervisor Services and Macro Instructions. (Although an EPIE
is provided only by the XA versions of the MVS and CMS operating systems,
one is created by the run-time library for all MVS and CMS systems.)
The
fpregs
field
is a pointer to an array of doubles that contains the contents of the floating-point
registers at the time of the signal and stored in the order 0, 2, 4, 6.
Notes on defining a handler |
If you define a handler for
SIGFPE
, you can determine what type of error caused the signal by testing
the
int_code
field of the information returned
by
siginfo
. You can also use this information
to reset the result of the computation by changing the value that
result
points to. Refer to the example in the description of the
siginfo
function for an illustration of this
technique.
USS Considerations |
When
SIGFPE
is managed by USS, the default action for
SIGFPE
is abnormal process termination, and
SIGFPE
is never converted into another
signal. If you want to handle
one or more of the
SIGFPDIV
,
SIGFPOFL
,
SIGFPUFL
, or
SIGIDIV
signals specific to SAS/C, you must define
SIGFPE
as a signal managed by SAS/C.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.