Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Tue, 19 Feb 2002 16:41:52 -0500 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: recvfrom and timeout signal Message-ID: <20020219214152.GG2344@redhat.com> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.23.1i On Tue, Feb 19, 2002 at 10:28:02PM +0100, Piotr St?pie? wrote: >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 ? Nope. Send an actual small working test case and someone will probably investigate it. cgf -- 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/