Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Zsh 4.3.12: subshell in midnight commander: precmd: 15: bad file descriptor



On Jul 18,  4:24pm, Peter Stephenson wrote:
} Subject: Re: Zsh 4.3.12: subshell in midnight commander:  precmd: 15: bad 
}
} On Mon, 18 Jul 2011 07:45:51 -0700
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > So it's the calling shell rather than the called shell that is closing
} > a descriptor that it shouldn't.
} 
} I don't think so: both lsof and sh -c 'pwd >&11' agree that the FD is
} still open in the lower shell.

Hrm.  So why does it work when starting 4.3.12 from 4.3.9?  How is 11
getting to be <= max_zsh_fd inside 4.3.12 that case, whereas it is not
when the outer shell is 4.3.12?
 
} See if this fixes it.

It prevents the specific error in question, but there are also going to be
changes needed here:

   2975                         fn->fd1 = (int)getintvalue(v);
   2976                         if (errflag)
   2977                             bad = 1;
*  2978                         else if (fn->fd1 > max_zsh_fd)
   2979                             bad = 3;
   2980                         else if (fn->fd1 >= 10 &&
   2981                                  fdtable[fn->fd1] == FDT_INTERNAL)
   2982                             bad = 4;

And what's going to happen when max_zsh_fd does in fact become greater
than the "unknown" descriptor?  Any problems with fdtable[x] having
bogus data?  Isn't closem() going to attempt to close a descriptor
that it shouldn't?

I wonder if the underlying problem doesn't somehow stem from this:

      * 27721: Src/compat.c [with unnecessary test removed], Src/exec.c,
      Src/system.h, Src/utils.c:  update zopenmax() not to examine huge
      numbers of file descriptors; only call it at initialisation;
      rationalise use of fdtable_size and expansion of fdtable.



Messages sorted by: Reverse Date, Date, Thread, Author