Subject: Re: poll(2) oddity
To: Christophe Kalt <>
From: Jaromir Dolecek <>
List: tech-userlevel
Date: 07/08/2002 00:10:35
Christophe Kalt wrote:
> yes, i could rewrite the code to have a dense set of struct
> pollfd, but the reason i didn't do it in the first place was
> to make the code simpler/shorter/more readable/..

Well, it could be written like:

	int len=0;
	struct pollfd pfd[MAXFDS]; 

	if (myfd1) {
		pfd[len].events = ...;
		pfd[len].revents = ...;

	if (myfd2) {

Readable and doesn't waste kernel memory. Note that copying
the poll array consumes some time, so generally the smaller
the array, the better.
But the speed would only become an issue with larger descriptor

> This whole thing got me worried and i just tested the limits
> on FreeBSD, Solaris, and Linux.  The first two limit the size
> to the maximum number of open files, while Linux doesn't seem
> to have any limit.

Upping the limit to maximum number of open files would prolly be sensible.
However, I personally don't see a problem in keeping it the way it is
(and documenting the behaviour).

Jaromir Dolecek <>
-=- We should be mindful of the potential goal, but as the tantric    -=-
-=- Buddhist masters say, ``You may notice during meditation that you -=-
-=- sometimes levitate or glow.   Do not let this distract you.''     -=-