Subject: Re: bug#22814: 25.0.91; Emacs runs out of file descriptors on OS X

From: Michael Albinus <[email-masked]>
Date: Fri, 04 Mar 2016 08:53:24 +0100

Eli Zaretskii <[email-masked]> writes:

Hi Eli,

>> Indeed, Emacs tries to read the docstring of the just fetched
>> function. And it tries to open etc/DOC for this, which fails due to the
>> missing file descriptor availability.
>> 
>> I don't believe we need to handle this case; if Emacs is running out of
>> file descriptors, anything could happen.
>
> The only part that might be worth improving is the error message: it's
> a far cry from what really went wrong.  If you can find a way of
> making it say something about "too many open files", that'd be all the
> improvement we can hope for.

I would apply the following patch:

--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/emacs-25/src/doc.c.~2e78353fabe11c768627c50e48375de5693ce7ee~
--- /home/albinus/src/emacs-25/src/doc.c
***************
*** 126,131 ****
--- 126,134 ----
    fd = emacs_open (name, O_RDONLY, 0);
    if (fd < 0)
      {
+       if ((errno == EMFILE) || (errno == ENFILE))
+ 	report_file_error ("Read error on documentation file", file);
+ 
  #ifndef CANNOT_DUMP
        if (!NILP (Vpurify_flag))
  	{
--8<---------------cut here---------------end--------------->8---

This ends up in the following error message:

Read error on documentation file: Too many open files, /home/albinus/src/emacs-25/lisp/emacs-lisp/cl-seq.elc

Is it OK to apply it to the emacs-25 branch, or shall it go to master?

Best regards, Michael.