Date: Tue, 09 Apr 1996 23:43:53 +0200 From: Marc van Kempen <marc@bowtie.nl> To: questions@freebsd.org Subject: select question Message-ID: <199604092143.XAA11392@nietzsche.bowtie.nl>
next in thread | raw e-mail | index | archive | help
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)) {
...
...
}
However, this piece of code will wait until a timeout occurs, when
I replace the '&tm' with NULL, it will even wait forever.
When I inspect the _comfd with
ioctl(_comfd, FIONREAD, &ret)
it will show me that a character is available to be read,
in fact when I try to read it with
read(_comfd, &ch, 1)
It will read the character just fine.
Are there any settings of the filedescriptor that will influence
the select behaviour? Or am I overlooking something else?
Regards,
Marc.
----------------------------------------------------
Marc van Kempen BowTie Technology
Email: marc@bowtie.nl WWW & Databases
tel. +31 40 2 43 20 65
fax. +31 40 2 44 21 86 http://www.bowtie.nl
----------------------------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604092143.XAA11392>
