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

Re: Do file descriptors survive to subshell?



It depends how the FD was opened.

> But the "survive FD" feature should work only for
> "exec zsh-5.2-dev-1", not "zsh-5.2-dev-1", shouldn't it ...

well, if you ran

  zsh-5.2-dev-1 3< myfile

you'd be a bit annoyed if FD 3 was closed, wouldn't you?
And of course 0, 1 and 2 are left open.

So for FDs opened by / known to the user, it's expected that they'll
survive; internal FDs used by the shell should be closed.  One example
of an FD the shell uses internally is for terminal management --- we
don't do this directly on the user-visible FDs for reasons I don't
think I ever fully understood.  Because this is opened early, it's
usualy FD 10, i.e. just outside the easily accessible range (that
traditionally shells keep away from allowing you to manipulate
directly) 0 to 9.

pws



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