[SunHELP] hang in signal handler

Hiro Zhu Dingze.Zhu at Sun.COM
Fri Feb 20 01:24:25 CST 2009


Hi people:

I have a question regarding signal handler on Sun AMD, compiled with
(Cm64 option.


We need to setup a handler to ignore a SIGFPE and present user an error
dialog.


The simple sample below works fine on SPARC, but hangs in signal handler
sig_fpe_handler on AMD.

We use Sun Studio 10. If the sample is compiled with (Cm64, it hangs in
the signal handler. If it is compiled without it, the handler is
executed twice.

Do you have any recommendation how this can be fixed?



Thanks,
Dingze





#include <stdio.h>

#include <stdlib.h>

#include <sunmath.h>

#include <siginfo.h>

#include <ucontext.h>

#include <iostream.h>

#include <floatingpoint.h>

#include <signal.h>



//

//

//

typedef struct sigaction SIGACTION;



void my_def_handler(int sig, siginfo_t *sip, ucontext_t *uap)

{

cout<<"+++++++++++++++++++++++++++++++++++++++\n";

}



void sig_fpe_handler(int sig, siginfo_t *sip, void *)

{

cout<<"sig_fpe_handler\n";

}

int main(int argc, char** argv) {



ieee_handler("set","common",(void(*)())my_def_handler);



SIGACTION sa;

memset(&sa,0,sizeof(sa));

SIGACTION o_sa;

sa.sa_sigaction = sig_fpe_handler;

sa.sa_flags = SA_RESTART | SA_SIGINFO;



int sys_status = sigaction(SIGFPE,&sa,&o_sa);

cout<<"sys_status "<<sys_status<<'\n';

double a = exp((double)51000000);



cout<<a<<'\n';

return (EXIT_SUCCESS);

}



More information about the SunHELP mailing list