Zsh Mailing List Archive
Messages sorted by:
Re: Do file descriptors survive to subshell?
- X-seq: zsh-users 21878
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: Do file descriptors survive to subshell?
- Date: Mon, 12 Sep 2016 18:29:58 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=LVwlE6qvWNGTMc7vH/6DUxAvrk6q7RnQp8z8kyDUaTU=; b=tlHaL7AkDYH/MnIUGEiDYMwFqqO/DQ5JPSfpbmD6RsU8VVo3IJASG1ydLntOVi1bYI Avjv45bKw9KpfWpAeY9vgKg4FOSTH/0+P4iSFfKCvjW8mGkAp4DUi4TcZheUcmZLyq4u 99qR0c0v/c0KvqzdTQ+5MWI9ZmNymF2jB2Ujn5XpkxlWllhhIs+PlPLCPwlvXDPwHRh1 MSSighea8UrO9dcA0L3y04g6rw3FyvC1/FmMrH7/BHmIwEB/jDVs20MRglZZevLlIaV4 eCxI6BUgloGnkI/wWra50Y4Nr8QhOYJFix97YhdprmOpa1LEIcAKKadG0G3SYdLCzewP kPfA==
- In-reply-to: <firstname.lastname@example.org>
- List-help: <mailto:email@example.com>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CGME20160912160148eucas1p1c7f423821260c611c9b34fbe47bfcf86@eucas1p1.samsung.com> <CAKc7PVBMgptkuPOmrcevDwsOrcWzeqO03G8xfr-aGoDade2EQg@mail.gmail.com> <email@example.com>
OK, thanks. I was planning to use read -t -u on a descriptor obtained
by exported variable SOMETHING_ID, to differentiate between `exec
zsh-5.2-dev-1` and `zsh-5.2-dev-1`. If it would fail then it's
non-exec, regular start. Now I see that SHLVL should be used to
BTW., read -t -u seems to succeed as many times as there are lines in
a file (file descriptor), that's rather unexpected, it rather should
do some "read char, put char back" thing, or something not changing FD
position in file I would say
On 12 September 2016 at 18:19, Peter Stephenson
> 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.
Messages sorted by: