Thread: Maximum FD Number

  1. #1
    Registered User
    Join Date
    Oct 2008

    Maximum FD Number

    Hello all,

    Just some simple questions to verify I'm right in my expectations:
    I believe that whenever a file descriptor is opened it uses the lowest available file descriptor number, is that correct? If so, am I right in thinking I can get the maximum file descriptor number the program can ever get can be retrieved by calling getrlimit with RLIMIT_NOFILE? Because if you open exactly that many files (you can't open more), the maximum number would be RLIMIT_NOFILE.

    Is this correct?

    Thanks in advance

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    That's what the manual says
    This is a number one greater than the maximum value that the system may assign to a newly-created descriptor. If this limit is exceeded, functions that allocate a file descriptor shall fail with errno set to [EMFILE]. This limit constrains the number of file descriptors that a process may allocate.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Quote Originally Posted by Salem View Post
    That's what the manual says
    Ahh that wasn't in the {g,s}etrlimit manual ;-). Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 02-08-2009, 09:26 PM
  2. Shortest path algorithm with a maximum number of edges limit
    By blackslither in forum C Programming
    Replies: 4
    Last Post: 12-28-2008, 04:49 PM
  3. scanf oddities
    By robwhit in forum C Programming
    Replies: 5
    Last Post: 09-22-2007, 01:03 AM
  4. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  5. Random Number problem in number guessing game...
    By -leech- in forum Windows Programming
    Replies: 8
    Last Post: 01-15-2002, 05:00 PM