zsh-workers
 help / color / mirror / code / Atom feed
* $PPID not updated when the PPID changes (parent killed)
@ 2021-05-16 15:24 Vincent Lefevre
  2021-05-16 18:37 ` Bart Schaefer
  0 siblings, 1 reply; 23+ messages in thread
From: Vincent Lefevre @ 2021-05-16 15:24 UTC (permalink / raw)
  To: zsh-workers

Consider the following script:

#!/usr/bin/env zsh
echo $ZSH_VERSION
f() { grep PPid /proc/$$/status; echo $PPID }
f
kill -9 $PPID
sleep 1
f

Under Linux, I get:

zira% sh -c ./tst.zsh; sleep 2
5.8
PPid:   39867
39867
zsh: killed     sh -c ./tst.zsh
PPid:   1
39867
zira% 

i.e. $PPID is not updated when the PPID changes, i.e. the parent
process is killed.

The zshparam(1) man page says:

  PPID <S>
      The process ID of the parent of the shell.  As for $$, the value
      indicates the parent of the original shell and does  not  change
      in subshells.

This implies that it should be updated when the process ID of the
parent of the shell changes.

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


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-07-18 23:10 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-16 15:24 $PPID not updated when the PPID changes (parent killed) 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
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

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