NetBSD-Users archive

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

[Signal handler] Bug or feature ?


I'm trying to fix a strange bug in a program that perfectly runs on various Unix including NetBSD 4.x (sparc). I have installed NetBSD 5.1.2 on an amd64 class server and I have found a strange behavior.

        A minimal example :

volatile int flag;

flag = 0;

        code_retour = nanosleep(&temporisation, &temporisation);
        erreur = errno;

        if (flag == 1)
} while((code_retour == -1) && (erreur == EINTR));

SIGINT signal handler is :

interruption1(int signal)
        flag = 1;

When this process receives SIGINT, it doesn't exit. I have verified that signal handler is called and it is. But nanosleep() returns with EINTR error before signal handler is called. Thus, (flag == 1) expression may be false even if SIGINT is catched by process. And signal handler seems to run in a second thread (when process is built with libpthread).

Is there any solution to call (and return from) signal handler before returning from nanosleep() ?

        Best regards,


Home | Main Index | Thread Index | Old Index