RE: select() fails... sometimes

=?iso-8859-1?Q?Miguel_Angel_Garc=EDa_Grande?= (mgarcia@bjssoft.es)
Thu, 20 May 1999 08:28:45 +0200


Alex,

That was the point. Thank you very much! I really had no idea about that!
Thanks once again!
Regards.

Miguel Angel

-----Original Message-----
From: Alex Belits [mailto:abelits@phobos.illtel.denver.co.us]
Sent: 20 May 1999 01:29
To: mgarcia@bjssoft.es
Cc: linux-kernel@vger.rutgers.edu
Subject: Re: select() fails... sometimes

On Tue, 18 May 1999 mgarcia@bjssoft.es wrote:

> I have a problem using select() on several handles.
> It does work fine but, under some circumstances, it returns inmediately
ignoring the timeout argument, indicating that handle zero (stdin linked to
a socket via inetd) has something to read, but "read()" gets nothing at all.
>
> Once it happens it doesn't stop until something is received by some other
handle. It's very annoying since the CPU load grows enormeously.
>
> It always happens with stdin (zero). I've tried the following settings for
stdin without success:
>
> fcntl( 0, F_SETFL, O_NONBLOCK );
> setvbuf( stdin, NULL, _IONBF, 0 );
>
> Any ideas?

If select() set a bit in readfds, and read() on that fd returned zero,
it means that whatever is attached to that fd is finished, this fd
must be closed, and no further i/o should be attempted on it. In your case
stdin is a socket, and other end closed it or disconnected for whatever
other reason.

--
Alex

---------------------------------------------------------------------- Excellent.. now give users the option to cut your hair you hippie! -- Anonymous Coward

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/