09-27-2009
7,
0
Join Date: Aug 2009
Last Activity: 28 September 2009, 12:56 AM EDT
Posts: 7
Thanks Given: 0
Thanked 0 Times in 0 Posts
why multiple SIGINT raises when i hit C-c
hi,
in my application, i have set up to capture SIGINT and execute a handler.the problem is whenever i hit C-c, multiple SIGINT are sent to the application.I have blocked the SIGINT right after catching the first one but it is unsuccessful.Here is what i do :
jmp_buf main_loop;
int main()
{
signal(SIGINT,CleanExit);
sigset_t set;
sigset_t old_set;
sigemptyset(&set);
sigemptyset(&old_set);
sigaddset (&set, SIGINT);
// run other threads ...
while( 1 )
{
if ( setjmp (main_loop) )
{
pthread_sigmask(SIG_BLOCK,&set,&old_set);
/// Clean up and shut down threads
pthread_sigmask(SIG_UNBLOCK,&set,&old_set);
break;
}
}
printf("\nbye!\n");
return 0;
}
void CleanExit()
{
shutdownThreads = 1;
longjmp (main_loop, 1);
}
The problem is the CleanExit method runs 3 to 4 times which means the pthread_sigmask(SIG_BLOCK,&set,&old_set); has not done the job.
So what is the problem?
My application is running in mulinux.
Thanks in advance,
Sedighzade