Re: Proper use of select() parameter nfds? - Mailing list pgsql-hackers

From Alex Pilosov
Subject Re: Proper use of select() parameter nfds?
Date
Msg-id Pine.BSO.4.10.10107060943390.7004-100000@spider.pilosoft.com
Whole thread Raw
In response to Proper use of select() parameter nfds?  (Matthew Hagerty <mhagerty@voyager.net>)
List pgsql-hackers
On Fri, 6 Jul 2001, Matthew Hagerty wrote:

> I take this to mean that each descriptor set contains n descriptors and I 
> am interested in examining the first nfds descriptors referenced in my 
> sets.  I also understood it to mean that nfds has absolutely nothing to do 
> with the actual *value* of a descriptor, i.e. the value returned by 
> fopen(), socket(), etc..  Is this correct thinking?  What got me 
> second-guessing myself was a use of select() that seems to indicate that 
> you have to make sure nfds is larger than the value of the largest 
Correct.
<snip>

> Any clarification on how nfds should be set would be greatly appreciated.

Just like you said:
"you have to make sure nfds is larger than the value of the largest
filedescriptor". 


Reason being: kernel has to know how large is the mask passed to it, and
how far does it need to look.

-alex





pgsql-hackers by date:

Previous
From: Zeugswetter Andreas SB
Date:
Subject: AW: AW: Re: Backup and Recovery
Next
From: Peter Eisentraut
Date:
Subject: Re: Database Users Management and Privileges