NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [Signal handler] Bug or feature ?



* BERTRAND Jol (joel.bertrand%systella.fr@localhost) wrote:
> volatile int flag;
> 
> flag = 0;
> 
> do
> {
>       code_retour = nanosleep(&temporisation, &temporisation);
>       erreur = errno;
> 
>       if (flag == 1)
>       {
>               exit(0);
>       }
> } while((code_retour == -1) && (erreur == EINTR));
> 
> SIGINT signal handler is :
> 
> void
> interruption1(int signal)
> {
>       flag = 1;
>       return;
> }
> 
> When this process receives SIGINT, it doesn't exit. I have verified 
> that signal handler is called and it is.
If there is nothing wrong, it is very strange.
I tried coding exactly what you did.
On my 6.0_RC2 (i386), it does ``exit'' after SIGINT delivered to the process.

> But nanosleep() returns with EINTR error before signal handler is called.
On my machine, I can verify that signal handler is called before nanosleep() 
returns.

> And signal handler seems to run in a second thread (when process is built
> with libpthread).
In my test, I did not link -lpthread.

>       No, testing flag isn't redundant as I have to catch SIGINT and 
>       SIGUSR1. I have written a simple test to see what's happening with only 
> one 
> signal.
It's not redundant in this case.
But it's redundant in case setjmp()/longjmp() are used in my previous post.

Cheers,
-- 
Pongthep Kulkrisada
 
"UNIX is basically a simple operating system,
but you have to be a genius to understand the simplicity."
-- Dennis M. Ritchie


Home | Main Index | Thread Index | Old Index