[cs631apue] Openmax.c fails earlier than expected
Jan Schaumann
jschauma at stevens.edu
Mon Sep 14 22:28:26 EDT 2020
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
More information about the cs631apue
mailing list