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: How to detect that Zsh startup is result of exec zsh?
Date: Tue, 13 Sep 2016 15:19:03 +0200	[thread overview]
Message-ID: <CAKc7PVAGqeJK=kdpQ9hSBcgpJmn639X94BU0CoNR2m6L2VBfcg@mail.gmail.com> (raw)
In-Reply-To: <20160913140643.56f99ccf@pwslap01u.europe.root.pri>

On 13 September 2016 at 15:06, Peter Stephenson
<p.stephenson@samsung.com> wrote:
> On Tue, 13 Sep 2016 14:23:23 +0200
> Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
>> Hello,
>> first `exec zsh` can be detected via SHLVL. It will be "1". And some
>> other variable set in .zshrc earlier will be non-zero. But what with
>> `exec zsh` ran from sub-shell?
>
> More widely, in fact, because fork and exec are so basic to UNIX-like
> process handling it's often not possible, and usually not useful, to
> tell this sort of thing apart.
>
> So the real question, as so often, is what you are actually trying to
> do?  What makes it necessary that you treat the cases differently?  If
> you can address that there may be an answer.

I'm assigning unique ID to every Zsh. If one runs Zsh in side Zsh,
either by exec or by new Zsh, the ID is inherited. However, there's
Tmux. There, ID is not inherited in both cases – person opening new
pane gets new Zsh, with new ID. But the exec case could still inherit
ID – replacing Zsh inside Tmux is fine to inherit ID. That's why I
need to differentiate the two

Best regards,
Sebastian Gniazdowski


  reply	other threads:[~2016-09-14  0:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20160913122504eucas1p121867b112b7f08e125a324230d8296df@eucas1p1.samsung.com>
2016-09-13 12:23 ` Sebastian Gniazdowski
2016-09-13 13:06   ` Peter Stephenson
2016-09-13 13:19     ` Sebastian Gniazdowski [this message]
2016-09-13 13:30       ` Peter Stephenson
2016-09-15  6:31         ` Sebastian Gniazdowski
2016-09-15 17:54           ` Lawrence Velázquez
2016-09-15 18:02             ` 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='CAKc7PVAGqeJK=kdpQ9hSBcgpJmn639X94BU0CoNR2m6L2VBfcg@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).