From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29180 invoked from network); 18 May 2021 15:58:02 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 18 May 2021 15:58:02 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1621353482; b=AonYxhevxtn/mUHrJMoh4ZL41FrIlhKGq8jgCZAsZ0CaE51UGtM8LZra21RaXkQTUlVfUFf6pi +U6hvI+2kG5cj/lQGamYSssuvaIU2rUNcPqAkd70uhVcjt4/zKUIuqKGorOdARmTF5KheQN4Kk Oqxmy1J3J6A4bM8xWhu/AYDhC3FMGRlFltM5G8KjrixCo0A/Mty95BmhOTcg/KkL11dJwMHo9A bMGUD1/gPSr5rVnoLHwNZO9Bi5XU8O0D7ZIt6kE+xsLmttZy8ADEu4wftQKRPe5uPClzGPtYN0 ybtW1vujLpc0Ffh2Zl0LAdMGZYUyq2xL4h4h3m4ZKQXWKQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay8-d.mail.gandi.net) smtp.remote-ip=217.70.183.201; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1621353482; bh=5nO5dmVNkzhMUo3ebQKTZpH+vFL3zxJ+8NqUYcHedB8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:From:Date:DKIM-Signature; b=0oaV7guJFRPrb+/UbtmTFwePyxlyE55egusfzI4YFekBiwRbHdsIIs6zS5cCNTf6myXz7sWivU 6werbhhg8pdlaydVlhwJEybWt5usBNrRwsUTgONAQ0l8uPWE+bfP7kj5E2sYpaLgjitPjwNiWT OXRoGKa8nUzb+SLYMzAGtE2PcX3gFOuQYu3dWZ5Ip6pwyHo/Jmbvik7zQQY7D8LyUFKlkPIJ5g EveVRsaVVjGv8tSHyAbpKc30fRu/HKkp/Siz/Wz/X88sziHJjz5uxVoOI8C+xfSG6zcbEX6LgI 7FWEmsOqbwxU9IeZ1ujkpddNOkK/BU89PaYP9gjOatEqqg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:To:From:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=dzCMl3kWnOtHjrYRMVzN1RytyNc8V3XYySnXpobfORQ=; b=YVLF9BNZ/PsKn+E8+CYhGkfFOV kbxyP/QozNNxu1tbn12nBTXeBUXJrY9yC0xjFX/DQ2wMS5UUi9w07inOGslXYxOTomava/cxDT8Sv +XM3nyCCVa8JgFgJCtMYskU9XUZvymguFnLUqadjm/xOngJ0exW5wFo6CBIAerkrRxRNRchYsg4C5 xu5/mBosM/eMojJJ5N3gDV/M+GncfgZw7Zkk++hvkJ7okL2EpIs2cObbpjUrkADOR86x/6/uoQyIC yLZaElq0PujWAI+umqEEwawC+bJpn1OznrWjOIosRzshsRNRtRQdzrEUrqNQU7x13aK9lSjyFiZ6l pi6DPi9w==; Received: from authenticated user by zero.zsh.org with local id 1lj26b-000In8-QB; Tue, 18 May 2021 15:58:01 +0000 Authentication-Results: zsh.org; iprev=pass (relay8-d.mail.gandi.net) smtp.remote-ip=217.70.183.201; dmarc=none header.from=chazelas.org; arc=none Received: from relay8-d.mail.gandi.net ([217.70.183.201]:34259) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1lj254-000ITp-Lv; Tue, 18 May 2021 15:56:26 +0000 Received: (Authenticated sender: stephane@chazelas.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id A5E6F1BF20B for ; Tue, 18 May 2021 15:56:25 +0000 (UTC) Date: Tue, 18 May 2021 16:56:24 +0100 From: Stephane Chazelas To: zsh-workers@zsh.org Subject: Re: $PPID not updated when the PPID changes (parent killed) Message-ID: <20210518155624.reh2mht2yfh6xcc5@chazelas.org> Mail-Followup-To: zsh-workers@zsh.org References: <20210516152418.GA39669@zira.vinc17.org> <20210517202608.GA3255290@zira.vinc17.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Seq: 48879 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: 2021-05-17 18:27:00 -0400, Phil Pennock: > On 2021-05-17 at 14:00 -0700, Bart Schaefer wrote: > > Still mulling over possible rewording (at the very least change "for" > > to "with" in that phrase). Suggestions that don't try to explain unix > > process hierarchy management in detail, are welcome. > > PPID > 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. > 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). [...] processes don't really create shell processes. A process may or may not fork itself, and then, maybe at a later point in either the parent or the child (generally the child) execute a shell (and generally, the parent will be waiting for that child). For PPID, POSIX specification of sh says: > Set by the shell to the decimal value of its parent process ID > during initialization of the shell Which is more accurate and clearer than any wording I can think of. Note that by the time the shell "initialises" (where it calls getppid() to fill in $PPID), the process that did fork the process that executed the shell ($$) may alread be gone. As in: $ ( (sleep 1; exec zsh -c 'print $PPID') &) 1 I kind of agree with Vincent that it would be more useful if $PPID reported the realtime value of the parent pid, but no other shell does it and that would break POSIX compliance, and we already have sysparam[ppid] as already noted. -- Stephane