zsh-workers
 help / color / mirror / code / Atom feed
From: Vincent Lefevre <vincent@vinc17.net>
To: zsh-workers@zsh.org
Subject: Re: $PPID not updated when the PPID changes (parent killed)
Date: Tue, 18 May 2021 10:15:20 +0200	[thread overview]
Message-ID: <20210518081520.GA3332066@zira.vinc17.org> (raw)
In-Reply-To: <CAH+w=7bywj1X1fyPLgpmo_OoqBEN8PjEDxDeKP-tMR_O4g04tg@mail.gmail.com>

On 2021-05-17 16:15:24 -0700, Bart Schaefer wrote:
> On Mon, May 17, 2021 at 3:27 PM Phil Pennock
> <zsh-workers+phil.pennock@spodhuis.org> wrote:
> >
> >   The initial parent process ID; that is, the process ID of the process
> >   which created this shell process, at the time that it did so.
> 
> This is pretty close to what I was thinking.  Does "at the time"
> really add anything?

It would be better without it.

> >   Just as for $$, the value is only set for the original shell and does
> >   not dynamically change for implicit subshells (as created for (list)
> >   and for pipelines).
> 
> Except (list) is an explicit subshell, isn't it?
> 
> > It's an attempt to be clearer that "if you run zsh within zsh,
> > that's not a subshell, sure _that_ gets $$ and $PPID reset".
> 
> Indeed.  I'm tempted to say
> 
>   Just as with $$, the value is updated only within a new shell
>   that increases $SHLVL, and not in other subshells.
> 
> And then clarify "a new shell" under SHLVL if necessary, but I hope it isn't.

The zsh man pages use "subshell" at various places. They should be
consistent on what a subshell is, perhaps have a clear definition
at one place, and say what happens when a subshell is created.

Note also that the following in the zshmodules(1) man page should be
updated too:

  sysparams
      A readonly associative array.  The keys are:
[...]
      ppid   Returns  the  process  ID  of  the  parent of the current
             process, even in subshells.  Compare $PPID, which returns
             the process ID of the parent of the main shell process.

This is even more confusing, because there are actually 2 differences
between $sysparams[ppid] and $PPID:

1. The fact that $sysparams[ppid] takes a new value in subshells, but
   not $PPID.

2. The fact that $sysparams[ppid] is updated when the parent process
   terminates, but not $PPID.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


  parent reply	other threads:[~2021-05-18  8:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-16 15:24 Vincent Lefevre
2021-05-16 18:37 ` Bart Schaefer
2021-05-17 20:26   ` Vincent Lefevre
2021-05-17 21:00     ` Bart Schaefer
2021-05-17 22:27       ` Phil Pennock
2021-05-17 23:15         ` Bart Schaefer
2021-05-18  0:30           ` Phil Pennock
2021-05-18  1:14             ` Bart Schaefer
2021-05-18  8:28             ` Vincent Lefevre
2021-05-18  8:15           ` Vincent Lefevre [this message]
2021-05-18 14:53             ` Bart Schaefer
2021-05-19  4:25               ` Bart Schaefer
2021-07-18 23:10                 ` Lawrence Velázquez
2021-05-18 15:18           ` Mikael Magnusson
2021-05-18 16:14             ` Peter Stephenson
2021-05-18 18:20               ` Bart Schaefer
2021-05-18 17:37           ` Martijn Dekker
2021-05-18 18:08             ` Bart Schaefer
2021-05-18 19:40               ` Martijn Dekker
2021-05-18 18:06           ` Stephane Chazelas
2021-05-18 18:12             ` Bart Schaefer
2021-05-18 18:50               ` $SHLVL origin (was: $PPID not updated when the PPID changes (parent killed)) Stephane Chazelas
2021-05-18 15:56         ` $PPID not updated when the PPID changes (parent killed) Stephane Chazelas

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=20210518081520.GA3332066@zira.vinc17.org \
    --to=vincent@vinc17.net \
    --cc=zsh-workers@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).