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

Re: $PPID not updated when the PPID changes (parent killed)



On Mon, May 17, 2021 at 3:27 PM Phil Pennock
<zsh-workers+phil.pennock@xxxxxxxxxxxx> 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?

>   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.

Aside, it's a bit odd that SHLVL isn't read-only.  Even assorted Bash
tutorials found by online search treat it as immutable (statements
like "$dog is only available at SHLVL 2") despite that it can be
arbitrarily messed with.




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