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

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



On Sun, May 16, 2021 at 8:24 AM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
>
> i.e. $PPID is not updated when the PPID changes, i.e. the parent
> process is killed.

$PPID means the ID of the process that spawned this one, not the
current value of getppid().

If you want the latter, it's $sysparams[ppid] (with the zsh/system
module loaded).  In fact the correct way to determine whether the
original parent has exited is to check (( PPID != sysparams[ppid] )).

We could enable a non-portable way to be alerted on parent exit using
prctl() now that HAVE_PRCTL is being checked by configure, but it
would be expensive to emulate in other cases.




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