Date:        Wed, 31 Jul 2019 09:23:11 +0100
    From:        Geoff Clare <g...@opengroup.org>
    Message-ID:  <20190731082311.GA32072@lt2.masqnet>

  | If the script is run from a program that is already near the
  | limit (and has no fd's marked close-on-exec), then it's entirely
  | possible.

Let me know when you see that happen in a non-contrived application,
and perhaps I will reconsider (if it isn't caused by a program bug).

  | I believe 32-bit versions of Solaris have the default limit set at
  | 255 (because the 32-bit FILE structure has the fd as a uchar).

That's on the low end of what's typical, but not unreasonable, and
beyond plenty for a shell.

  | I'll admit that EMFILE is rare, but given a combination of the
  | above factors it certainly can happen.

Yes, it can - but so infrequently and with consequences no
different than what happens with far more likely problems which
the shell cannot treat as "abandon hope and abort" that it really
is not worth worrying about.

  | Slow down?  You jest.  The shell is making a system call to open a
  | directory.  The time taken to check the errno value is negligible in
  | comparison to that.

Certainly, the extra time is small by comparison, but the opendir() and
its costs are required, that's how we make the algorithm work.  The
check for errno is not required, and is *extra* delay (albeit fairly
small) that isn't really useful for anything in practice.

When I get users complaining about their scripts behaving improperly
because they were affected by stray EMFILE errors that they did not
inflict upon themselves, then maybe I'll add a test for it.  Until
then it simply is not going to happen.

kre

Reply via email to