From owner-freebsd-hackers Mon Oct 11 8:18:50 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from bingnet2.cc.binghamton.edu (bingnet2.cc.binghamton.edu [128.226.1.18]) by hub.freebsd.org (Postfix) with ESMTP id 43EDE14BE7 for ; Mon, 11 Oct 1999 08:18:48 -0700 (PDT) (envelope-from zzhang@cs.binghamton.edu) Received: from sol.cs.binghamton.edu (cs1-gw.cs.binghamton.edu [128.226.171.72]) by bingnet2.cc.binghamton.edu (8.9.3/8.9.3) with SMTP id LAA25451; Mon, 11 Oct 1999 11:05:30 -0400 (EDT) Date: Mon, 11 Oct 1999 11:05:26 -0400 (EDT) From: Zhihui Zhang To: Ruslan Ermilov Cc: freebsd-hackers@FreeBSD.org Subject: Re: How to prevent a system call from restart? In-Reply-To: <19991011115506.A34243@relay.ucb.crimea.ua> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, 11 Oct 1999, Ruslan Ermilov wrote: > On Sun, Oct 10, 1999 at 03:16:43PM -0400, Zhihui Zhang wrote: > > > > I modify the day time client program from the Stevens' book and run it on > > both a Sun workstation and a FreeBSD machine. In the program, I use > > signal() and alarm() to set a 5 seconds timeout. The program works as > > expected on Sun (after I comment out the daytime line in the file > > /etc/inetd.conf) but not on the FreeBSD machine. > > > > Later I find out that the reason maybe the recvfrom() restarts > > *automatically* in FreeBSD. Why the default behaviour is different from > > SunOS? If I am correct about the reason, can anyone tell me how to prevent > > the recvfrom() from restart after receiving the SIGALRM signal? > > > > By the way, I also try the socket timeout option. It works immediately. > > > > Any help is appreciated. > > > Refer to the siginterrupt(3) manpage, it has all info you are looking for. Thanks! I add the following line after signal(), then it works: (void) signal(SIGALRM, sig_alarm); siginterrupt(SIGALRM, 1); <-- only add this line. -Zhihui To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message