c - How to get further information on SIGFPE signal? -
this the gnu c library reference manual
int sigfpe
the sigfpe signal reports fatal arithmetic error. signal covers arithmetic errors, including division 0 , overflow.
bsd systems provide sigfpe handler argument distinguishes various causes of exception. in order access argument, must define handler accept 2 arguments, means must cast one-argument function type in order establish handler.
but there no example on how access argument.
i did google work not find anything.
how can information?
as eof mentioned in comments, better way this, doesn't require formally broken casts, , bonus correctly documented, install signal handler using sigaction , sa_siginfo flag, , in si_code field of second parameter (type siginfo_t) can determine floating-point error occurred:
the following values can placed in
si_codesigfpesignal:
fpe_intdivinteger divide zero.
fpe_intovfinteger overflow.
fpe_fltdivfloating-point divide zero.
fpe_fltovffloating-point overflow.
fpe_fltundfloating-point underflow.
fpe_fltresfloating-point inexact result.
fpe_fltinvfloating-point invalid operation.
fpe_fltsubsubscript out of range.
source: linux sigaction(2) man page
the same list readily available on freebsd siginfo man page.
Comments
Post a Comment