From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 258AA23253 for ; Tue, 27 Feb 2024 08:05:20 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1709017520; b=f9rNc52d6CG7Bg4BdxZM328W/PoAEjTFh81K+cHjIIxgkaWzcWidzqInrASp/XuZ3pZh54iceV /0WSBk+10St5WU+j+PJor0C9nI18KDiFRpzlmwZS7s7oIyTlPZ32vtDk4LG69c+PHBntfcwZvS RXqroyyZpb1ayFRLzNQLwLFRxQAPnhgfGIHDdW5dMtQXZ8E86x2Jy2guZOaIV2W5jPhc7/t1gQ OegvRnAefFbVkTroExxcvJlXU9yO+S0NlBcgFfLxkfpN6e4Kc3M9GylHoUSJQeAK+FOTTVEa+g Gru11Uxy92O9GCnww6lLIaDjxRXvQSUoLGyzkBYZpfx4Ew==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay1-d.mail.gandi.net) smtp.remote-ip=217.70.183.193; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1709017520; bh=x2M2mn9TdcwolcmydXpoPY901LvV7rMLpTULSfuGmkY=; 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:Cc:To:From:Date:DKIM-Signature; b=TR/bfk8HITYfIThRvCHiU0xMn70V0rQ1ZF3IKho2euacrQ2xTPnzfd7+oBmlQC3MP9plwGPFMx 2/vNx9Gw2iCyrTflXlpRsoaZHjJEIvPXy5+qnGwzhSBF17dw8Su2Fq98utfIYDZCUE9ksb/Ftc bu01yI9HDCSHf0YTIwlNes/smPEmtBscEfug7ed3FZ0tkxgo6X6FWZhg9ywoW7Ul+u3xE11VMN 7Siqa/mj2kxdVWOGuIdCW7qYQ2fvqJ7SUisalh9hr0XlYoEfTb89TdXaggIW+1k06qwHWJhxth aLLyTMuar0rtWE5VCr38bWL2ooP+L16No6b3r+M8gmgXTA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; 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:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=/xyh+5jexaMCNiZq+EPfkndJ6i0P4zlafcPvew7/y7w=; b=XdN2zQ/3mPynoo23fEUl2RFiGE WASysYp3pSXuxNxwPKlWLoLAf4jl7c43zYkfhm8B+Vvwj+aJVUytJb0d7vsde16qvsWbhFJIrZMhC eRAvrtaTiVGn72wc4t2cvqXLEb2m/12GiiJ1Jd1H0bn5VQ78UwoZM4zpgVUOf9ul077cyUIaagvKk FiOapU68NbKtUD72BKQdQ7tC7W/LE18N3WSCdURZ6d/Mj49tNqnPDhzyLMed9r+29T35WbjMClQE6 ltKS+IqTWdRZFAOLfz9Be6arswUXxMpIcG/o5AxZ7TMjyeVCgxi/+/ZdaFQr+jpNZJ9NjkSuLIQyI ZDTLc/AQ==; Received: by zero.zsh.org with local id 1rerWi-000D5v-7p; Tue, 27 Feb 2024 07:05:20 +0000 Authentication-Results: zsh.org; iprev=pass (relay1-d.mail.gandi.net) smtp.remote-ip=217.70.183.193; dmarc=none header.from=chazelas.org; arc=none Received: from relay1-d.mail.gandi.net ([217.70.183.193]:37345) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1rerWS-000Cla-Pj; Tue, 27 Feb 2024 07:05:05 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id E5144240002; Tue, 27 Feb 2024 07:05:03 +0000 (UTC) Date: Tue, 27 Feb 2024 07:05:02 +0000 From: Stephane Chazelas To: Bart Schaefer Cc: Zsh hackers list Subject: Re: "kill -STOP" as noticed in ksh93u+ gitlab Message-ID: <20240227070502.ek5ocpwxm6cpp5gz@chazelas.org> Mail-Followup-To: Bart Schaefer , Zsh hackers list References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-GND-Sasl: stephane@chazelas.org X-Seq: 52621 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: 2024-02-26 13:26:37 -0800, Bart Schaefer: > > The kill built-in command now correctly refuses to issue SIGSTOP to the shell's own process if the shell is a login shell. > > Is this something we should consider for zsh? Commit log gives more info: > commit 8cc9a13deb3b29e30849d6c6c1cd4a48c5d2eb53 > Author: Martijn Dekker > Date: Sat Sep 16 01:17:13 2023 +0100 > > job_kill(): fix bogus assumption that login shell has PPID 1 > > Normally, suspending a login shell with SIGSTOP (e.g., kill -STOP > $$) will irrecoverably freeze the terminal session, so it is a good > idea to prohibit that. > > But job_kill() (called via the 'kill' built-in, b_kill()) assumes > that any login shell has a parent PID of 1, a.k.a. init. This may > have been valid on some systems back in the 1980s, but when people > started using graphical terminals (if not before), that assumption > became universally bogus. > > Some shells (at least yash) prohibit issuing SIGSTOP to self if > their process is the session leader. But even that doesn't always > hold. For instance, on macOS, the terminal creates a login(1) > process (the session leader), and the login shell is its child. > > So really the only thing we can reliably do is check for the > -l/--login/SH_LOGIN_SHELL shell option (as the 'suspend' built-in > already does; see 3ba4900e). (also note that suspend used to be an alias to kill -STOP $$ (yes, without the quotes around the expansion) in ksh93). So that's about extending an old (obsolete) behaviour to graphical terminal emulators and only for macos which is the only system that I've heard of where terminal emulators create a login shell. But, that seems wrong. It made sense in the 80s where if you froze your login session, you would have no chance to recover from it. But in the graphical emulator case, you could envisage one wanting to suspend their shell (login or not) and resume it later with a SIGCONT from another shell (in a different terminal emulator or different ssh session...). And doing that for login shells makes less sense than for session leaders especially considering it's even easier now to start a login shell with zsh --login or ARGV0=-zsh zsh. I've not seen any other shell that does that. -- Stephane