Re: process file descriptor limit handling

From: Chris Wright
Date: Wed Mar 09 2005 - 18:37:00 EST

* Ulrich Drepper (drepper@xxxxxxxxxx) wrote:
> Hash: SHA1
> The current kernel (and all before as far as I can see) have a problem
> with the file system limit handling. The behavior does not conform to
> the current POSIX spec.
> It might also be that some wording is getting in the specification which
> will allow the current kernel behavior to continue to exist. More
> through a loophole, but still.

This seems the case. SuS v3 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.

{OPEN_MAX} file descriptors are currently open in the calling process.

Maximum number of files that one process can have open at any one time.
Minimum Acceptable Value: {_POSIX_OPEN_MAX}

So, one view says your test program is within the spec, since the new fd
is still one less than the current rlimit.

Anyway, here's a simple patch that would fail the second setrlimit, as you

Linux Security Modules
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at