From owner-freebsd-hackers Tue Apr 20 3:28:42 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from gidgate.gid.co.uk (gidgate.gid.co.uk [193.123.140.1]) by hub.freebsd.org (Postfix) with ESMTP id C6A3A14C9D for ; Tue, 20 Apr 1999 03:28:38 -0700 (PDT) (envelope-from rb@gid.co.uk) Received: (from rb@localhost) by gidgate.gid.co.uk (8.8.8/8.8.7) id LAA22368; Tue, 20 Apr 1999 11:25:33 +0100 (BST) (envelope-from rb) Message-Id: <3.0.6.32.19990420112535.007d27d0@192.168.255.1> X-Sender: rbmail@192.168.255.1 X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Tue, 20 Apr 1999 11:25:35 +0100 To: Graham Wheeler From: Bob Bishop Subject: Re: Using select() to implement a delay Cc: hackers@FreeBSD.ORG In-Reply-To: <199904200921.LAA09941@cdsec.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, Most likely your select() is taking a signal; truss might be revealing. You should in theory be able to write something along the lines of: do r = select(0, 0, 0, 0, &tv); while (r == -1 && errno == EINTR); but AFAIK tv won't get updated correctly, see the BUGS entry in select(2). At 11:21 20/04/99 +0200, Graham Wheeler wrote: >Hi all > >I have an interesting problem. I have a routine to implement delays: > >void Sleep(int secs, int usecs = 0) >{ > struct timeval tv; > tv.tv_sec = secs; > tv.tv_usec = usecs; > (void)select(0, 0, 0, 0, &tv); >} > >I am using this both because it gives better resolution than sleep(), >and also because it doesn't require the use of SIGALRM, which I am >using elsewhere. > >On my development machine, Sleep(60) does exactly what is expected. On >my clients machine, Sleep(60) returns immediately. Both are running >FreeBSD 2.2.7. I don't have access to the clients machine, which is >in another city, and has no development environment, so I can't run gdb, >although it may not give away anything in any case. > >Does anyone have any ideas why the one works and the other doesn't? > >TIA >gram >-- >Dr Graham Wheeler E-mail: gram@cdsec.com >Citadel Data Security Phone: +27(21)423-6065/6/7 >Firewalls/Virtual Private Networks Fax: +27(21)24-3656 >Internet/Intranet Network Specialists >Data Security Products WWW: http://www.cdsec.com/ > > > > > >To Unsubscribe: send mail to majordomo@FreeBSD.org >with "unsubscribe freebsd-hackers" in the body of the message > > -- Bob Bishop +44 118 977 4017 rb@gid.co.uk fax +44 118 989 4254 (0800-1800 UK) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message