[LTP] [PATCH v2 10/13] getdtablesize01: Handle ENFILE errno

Punit Agrawal punit.agrawal@arm.com
Fri Dec 1 16:30:51 CET 2017


Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> > When process has exhausted the maximal number of file descriptors it can
>> > open we are supposted to fail with EMFILE, when that happened to the
>> > whole system before we hit the per process limit we get ENFILE. So I was
>> > suggesting that we may as well check that we were able to open expected
>> > number of file descriptors and that the last open() failed with EMFILE.
>> 
>> But isn't that we check already ? I mean, the test already gets the limit
>> on number of open files for this process and tries to open one less fd.
>
> As far as I can tell it tries to open as much fds as is the limit, the
> loop is kind of silly since it starts at 1 and the condition is <= but
> that should call open the open number of limit times.
>
>> So I don't think we should check that error. If we get that error, something
>> else is wrong in the accounting and should be treated as an error.
>
> But the loop never finishes and the open() always fails with EMFILE
> because process has at least three fds opened when it starts (the
> stdin/stdout/stderr are inherited from the parent). Hence the loop is
> always broken on fd == -1.
>
> I guess that we may as well change the loop to infinite one, which would
> be less confusing in this case.

Ok, I've changed the for loop to start from 0 and dropped the stopping
condition.

Thanks,
Punit


More information about the ltp mailing list