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