LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   sem_wait() interrupted by unknown signal (https://www.linuxquestions.org/questions/programming-9/sem_wait-interrupted-by-unknown-signal-804441/)

cjohn124 04-27-2010 01:49 AM

sem_wait() interrupted by unknown signal
 
Hi, all:

I have hit a strange problem recently. One server application (nps_linux) exits when the printer (run in WindRiver OS) enters deep sleep mode.

Inspection shows it is due to sem_wait() returns EINTR, which means it is interrupted by some system signal, right?

A simple fix is to put sem_wait() into a loop, and ignore errno EINTR. That works. Still, I want to go one step further, to find out what signal is sent to the service app and ignore it. However, I can't find the signal.

Here is the code snippet and the log:
--------
/* code snippet */
static void signal_handle(int signal_number)
{
LOGINFO("%s(): receive %d\n", __func__, signal_number);
return;
}

int
main( int argc, char *argv[] )
{
...
sigterm_action.sa_handler = &signal_handle;

for(i=1; i<100; i++)
{
sigaction(i, &sigterm_action, NULL);
}
...
if (sem_wait(&gTerminateSemaphore) != 0)
{
LOGERROR("%s(): sem_wait() failed, errno = %i.", __func__, errno);
}

close_down_nest();
...
}

/* log */
<nps_linux> (Mon Apr 26 2010 23:21:57.753) <p3685,t808678736,nps_main.c,716>
ERROR>> main(): sem_wait() failed, errno = 4.
<nps_linux> (Mon Apr 26 2010 23:21:57.753) <p3685,t808678736,nps_main.c,345>
ENTER>> close_down_nest()
--------
What is strange is, when sem_wait() returns with EINTR, no signal is received.

Is it possible? If the service doesn't receive any signal when the system is entering deep sleep, what else can make sem_wait() returns with EINTR?

Confused and looking forward to help,
cjohn124


All times are GMT -5. The time now is 06:55 AM.