This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
recvfrom and timeout signal
- From: Piotr Stępień <pstepien at aspco dot com dot pl>
- To: <cygwin at cygwin dot com>
- Date: Tue, 19 Feb 2002 22:28:02 +0100
- Subject: recvfrom and timeout signal
Hi All,
I try to implement timeout for recvfrom:
struct sigaction action;
action.sa_handler = alarm_signal;
action.sa_flags = 0;
sigemptyset(&(action.sa_mask)); /* ignore all known signals */
sigaction(SIGALRM,&action,NULL); /* ensures that SA_RESTART is NOT set */
alarm(TIMEOUT);
int st=recvfrom(sockfd,buff,sizeof(buff),0,(sockaddr*)&srv_addr,&sz);
if(st == -1){
if(errno==EINTR){
/* timeout */
}else{
alarm(0); /* reset alarm */
}
}
but the process is never woken by SIGALRM when no packet is received.
The recvfrom waits forever.
Has anybody an idea what can be wrong ?
--
Piotr Stepien
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/