LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Timers SIGRTMIN is causing Socket Read to error on EINTR (https://www.linuxquestions.org/questions/programming-9/timers-sigrtmin-is-causing-socket-read-to-error-on-eintr-653411/)

wkhoo 07-03-2008 03:12 PM

Timers SIGRTMIN is causing Socket Read to error on EINTR
 
never used timers before and currently I am experiencing the problem.

I have setup timers to trap on a SIGRTMIN.
I have a blocking socket that does read_socket. whenever the timer expire, the read_socket will return with - and EINTR.

after much searching I discover the issue comes from a Blocking socket implementation.
I cannot change the socket to non-blocking as it will eat up the CPU.

Is there a different way I can implement timers?
or is there a way I can setup a blocking socket to prevent the return of EINTR?

Alexlun 07-04-2008 11:05 PM

A better solution is continue to read socket when occurs some EINTR signal.

for example
while(1)
{
ret = read(sockfd...);
if ( ret < 0 && errno == EINTR ) continue;

//do other logic
}


All times are GMT -5. The time now is 09:42 PM.