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,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22571 invoked from network); 14 Apr 2022 05:14:03 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 14 Apr 2022 05:14:03 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1649913243; b=b8ETyKgcgu8o/dQgCTapalgdpMIVwqoOrDy3X81SjRSJOUFqts61XWX86Lug9GgymdMaQm3wQY bNPIJT+L/Jm99qsAFqVhVK2vW2vkJ7xgRpgyvSC0h/65ljXMgR2y4xjuavz0qkdRjUs2lA4plg FripO7ownJTU/UvOxsLDua5LhAwbalUjXuU/R5LILQn7q19plT5Bhrv32kVCmKfpcT5l2livjM C0xA32XccWeJk5nc3UAvnuo3jEaKi5ywyogS/g8iCjN5lgOffUGJGdO8WyrpNUZn0B/rA3neGf nGQ+GmseA56imJwal9EoLRRan1qbt2ca9nc87hKkxiPE9Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (so254-31.mailgun.net) smtp.remote-ip=198.61.254.31; dkim=pass header.d=klanderman.net header.s=mg header.a=rsa-sha256; dmarc=none header.from=klanderman.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1649913243; bh=oEkpDk7YzBonQUlBi01/ZWAuV/W6f27B4qzotFmqF48=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version: References:Message-ID:In-Reply-To:Date:Reply-To:Subject:To:From: DKIM-Signature:DKIM-Signature; b=dAH0cyjNphJutOpQzXnXUVariJ6sAQ0Yfe2Dy/TGnk3EsDVRVIka0bCND0pr6aK6jJXDFhAox3 becOz12rCSYtvAEBhQdIJg88erdLys0z1kYPk2s1QuyhIwVKndlBs6tBlONE9Xnq8eEUle2JJc sJgn5oTHe7Vi/Z0IeCzVbAAF06HBojaT7MMTzjtpM8xu7PWueZGFZ3ETWqXPRCnQbrVD1BxlmD JCEDZkCRSHY6R0B/3TUTOeVVjRf0Desr/meqTtVBfkyiv8aBJQF/7KFaA3JVYc3/+phB2kbVqL MEha6TRCunXBGIWuMjYAqvXLFBCz8RMDoiTLRb4mEHmA1Q==; 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:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:In-Reply-To:Date:Reply-To: Subject:To:From:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=+xMvZTVoCzw03VN/yrNCFYQF+oBME3Nj3E3m1NbSfS8=; b=Akt5PP5yPZYB/tXiD64FyCLjUS ol6rF+RHkeGH1saP/E8qDERxHtCVL2sJnl0NMJM/yKBTr7E4j3VRsqEmILgo5SoJ4L3svFaerxOnh R4ZvQj1racMeAytEwpuCbsSViATZzWgqTB2ZcOQ6fr/R2QUZ6PMyNdV6rFXw3eTvmW+GoWyvSXMau KinAA2hy2V8jq6D1mpyZfoY7KbB1eT8z979jYzcj743L5FEK8rV2tUiBkfY/CdGLoo5HdJKkpm4Bb BxDIQ8V9WuGuXuwYwYx7+mmse/EfW9Ypeql12rQrXb0NobNaNj6Oyi8H3nynRnqPNOqsn/f9YB+7g LBOERc5A==; Received: from authenticated user by zero.zsh.org with local id 1nernt-000L85-BQ; Thu, 14 Apr 2022 05:14:01 +0000 Authentication-Results: zsh.org; iprev=pass (so254-31.mailgun.net) smtp.remote-ip=198.61.254.31; dkim=pass header.d=klanderman.net header.s=mg header.a=rsa-sha256; dmarc=none header.from=klanderman.net; arc=none Received: from so254-31.mailgun.net ([198.61.254.31]:51238) by zero.zsh.org with utf8esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nernK-000KoR-EL; Thu, 14 Apr 2022 05:13:27 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=klanderman.net; q=dns/txt; s=mg; t=1649913206; h=Content-Transfer-Encoding: Content-Type: MIME-Version: References: Message-ID: In-Reply-To: Date: Reply-To: Subject: Subject: To: To: From: From: Sender: Sender; bh=+xMvZTVoCzw03VN/yrNCFYQF+oBME3Nj3E3m1NbSfS8=; b=KVD17TKplQkxd9HUFp5qxXrba2wIubOJmn5xsAjyFrXe7uPzFKJk6KPOXLgrGT0LMdRfRzDv hHaP+gR6cdu96qUWw+S+pl0SbzEIUbBhoN975z/CoG4YgJ9bp45iTco+/yL8sBDwRgFjY4CT cbuF559D6ksxyahPR3YzX/35vrw= X-Mailgun-Sending-Ip: 198.61.254.31 X-Mailgun-Sid: WyIwZjNkNyIsICJ6c2gtd29ya2Vyc0B6c2gub3JnIiwgIjk3ZGJkOCJd Received: from smtp2.klanderman.net (smtp2.klanderman.net [142.93.10.110]) by smtp-out-n01.prod.us-east-1.postgun.com with SMTP id 6257ad74514839a819b02357 (version=TLS1.3, cipher=TLS_AES_128_GCM_SHA256); Thu, 14 Apr 2022 05:13:24 GMT Received: from lwm.klanderman.net (pool-72-93-77-73.bstnma.fios.verizon.net [72.93.77.73]) by smtp2.klanderman.net (Postfix) with ESMTPSA id 1429540CE8; Thu, 14 Apr 2022 01:13:24 -0400 (EDT) Received: by lwm.klanderman.net (Postfix, from userid 1000) id E46EF29E00A7; Thu, 14 Apr 2022 01:13:23 -0400 (EDT) From: Greg Klanderman To: zsh-workers@zsh.org Subject: Re: using trap function to cleanup and exit? Reply-To: Greg Klanderman Date: Thu, 14 Apr 2022 01:13:23 -0400 In-Reply-To: (Lawrence =?iso-8859-1?Q?Vel=E1zquez's?= message of "Sun, 10 Apr 2022 14:15:15 -0400") Message-ID: <874k2wz1qk.fsf@lwm.klanderman.net> User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.24 (linux) References: <25170.64465.301441.247673@lwm.klanderman.net> <87fsmk2a03.fsf@lwm.klanderman.net> <87czho2967.fsf@lwm.klanderman.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Seq: 50060 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: >>>>> On April 10, 2022 Lawrence Vel=E1zquez wrote: > On Sun, Apr 10, 2022, at 12:30 PM, Greg Klanderman wrote: >> With no traps of either type, should the child sleep remain after the >> script is killed by a signal? > Child processes are not automatically terminated if their parent > dies. In general you have to handle this yourself (for example, > https://mywiki.wooledge.org/SignalTrap#When_is_the_signal_handled.3F). > I don't know if zsh has some special sauce to streamline this, as > I rarely write scripts that spawn long-running processes. Thank you Larry, of course that link is describing bash, not zsh, and it's not immediately clear if they do/should behave the same in this regard. It does say that if an external foreground command is executing in bash, that signals will not be handled until the command terminates. And so the workaround is to background the command, in which case that command will not be killed when the script is killed. This is fine, because you have the ability to capture the PID when you background it, and so can handle killing it if you so desire. The zsh script I posted has a foreground sleep, which does not seem to prevent a signal from being handled as described for bash. But with a foreground command you have no ability to handle killing it when you die, so it would only make sense to me for zsh to do that. I need to study this and what Bart wrote a bunch more, but unfortunately will not be able to do so for at least another week. thank you, Greg