From owner-freebsd-questions Wed Apr 10 06:56:20 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id GAA07854 for questions-outgoing; Wed, 10 Apr 1996 06:56:20 -0700 (PDT) Received: from lenzi (ra11.dial.ufsc.br [150.162.246.11]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id GAA07720 for ; Wed, 10 Apr 1996 06:54:50 -0700 (PDT) Received: (from lenzi@localhost) by lenzi (8.6.12/8.6.12) id KAA01616; Wed, 10 Apr 1996 10:55:56 -0300 Date: Wed, 10 Apr 1996 10:55:54 -0300 (EST) From: "Lenzi, Sergio" X-Sender: lenzi@lenzi To: Marc van Kempen cc: questions@FreeBSD.ORG Subject: Re: select question In-Reply-To: <199604092143.XAA11392@nietzsche.bowtie.nl> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Tue, 9 Apr 1996, Marc van Kempen wrote: > > Hi, > > This is not really FreeBSD related, unless it's a FreeBSD bug. But > I wonder under which conditions a select will fail? > > I have opened a comport read-write and want to wait for characters > to become available, so I do a: > > tm.tv_sec = 0; > tm.tv_usec = timeout; /* timeout to wait for reply */ > FD_ZERO(&readfds); /* clear the read filedescriptor set */ > FD_SET(_comfd, &readfds); /* select the _comfd to wait for */ > if (select(1, &readfds, NULL, NULL, &tm)) { ^ the select call should be:select(_comfd+1,&readfds....) I use this way and it works. Sergio lenzi.