[cs631apue] Openmax.c fails earlier than expected

Charles Magyar IV cmagyar at stevens.edu
Tue Sep 15 15:53:27 EDT 2020


If errno == EMFILE, the errno = 24.  "Too many open files" according to the man page of errno.

In the else block, errno equals 23 during my run.
This is ENFILE, and means "Too many open files in system.
 Maximum number of file descriptors allowable on the system has been reached and a request
 for an open cannot be satistfied until at least one has been closed."

So it turns out that the entire system is simply out of space.

In another test, I ran
 >  fstat | wc -l
> 249

openmax.c shows me 4 open files, and fails on #3248 with ENFILE.

249 + 3247 > 3404, so I'm unsure how the limit of ENFILE is determined.

I'll look into it later and get back to everyone with what I find.






________________________________
From: cs631apue-bounces at lists.stevens.edu <cs631apue-bounces at lists.stevens.edu> on behalf of Jan Schaumann <jschauma at stevens.edu>
Sent: Monday, September 14, 2020 7:28 PM
To: cs631apue at lists.stevens.edu <cs631apue at lists.stevens.edu>
Subject: Re: [cs631apue] Openmax.c fails earlier than expected

Charles Magyar IV <cmagyar at stevens.edu> wrote:

> I change the limit to unlimited, and the program starts to throw issues at file # 3249.  I had 8 files already open.
> With 8 files open, I would expect it to fail at 3396.

Ah, I see what's going on here.

Take a close look at _when_ we generate the error
message, and _what_ the error message is exactly.

>         for (int i = count; i <= num + 1; i++) {
>                 if ((fd = open("/dev/null", O_RDONLY)) < 0) {
>                         if (errno == EMFILE) {
>                                 printf("Opened %d additional files, then failed due to limit.\n", i - count);
>                                 break;

What is 'errno' here, and what is the error message
printed by strerror(errno)?

>                         } else {
>         fprintf(stdout, "File # %d err\n",i);
>         fprintf(stderr, "Unable to open '/dev/null': %s\n",
>                                                 strerror(errno));
>                         }

And what is 'errno' _here_, and what is the error
message printed by strerror(errno)?


I'm sure you can pinpoint the difference - then go one
step further and see if you can find out what the
difference in the numbers you expected and the ones
you observed are.

-Jan
_______________________________________________
cs631apue mailing list
cs631apue at lists.stevens.edu
https://lists.stevens.edu/mailman/listinfo/cs631apue
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20200915/4e1171b6/attachment.html>


More information about the cs631apue mailing list