zsh-users
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Do file descriptors survive to subshell?
Date: Mon, 12 Sep 2016 18:29:58 +0200	[thread overview]
Message-ID: <CAKc7PVCXG-4D4cJ_Hb849pawBtgx3mE3Rx71JSvjeY2gty8bAg@mail.gmail.com> (raw)
In-Reply-To: <20160912171959.2516a91e@pwslap01u.europe.root.pri>

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
differentiate that?

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

Best regards,
Sebastian Gniazdowski


On 12 September 2016 at 18:19, Peter Stephenson
<p.stephenson@samsung.com> wrote:
> 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


  reply	other threads:[~2016-09-12 17:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20160912160148eucas1p1c7f423821260c611c9b34fbe47bfcf86@eucas1p1.samsung.com>
2016-09-12 15:29 ` Sebastian Gniazdowski
2016-09-12 16:19   ` Peter Stephenson
2016-09-12 16:29     ` Sebastian Gniazdowski [this message]
2016-09-12 18:24       ` Bart Schaefer
2016-09-13  8:54         ` Sebastian Gniazdowski
2016-09-14 17:53           ` Bart Schaefer
2016-09-15  6:41             ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKc7PVCXG-4D4cJ_Hb849pawBtgx3mE3Rx71JSvjeY2gty8bAg@mail.gmail.com \
    --to=sgniazdowski@gmail.com \
    --cc=p.stephenson@samsung.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).