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 31748 invoked from network); 10 Apr 2022 16:30:34 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Apr 2022 16:30:34 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1649608234; b=ZxeYSHo2ugg+AIzBScH7N5zBUJ+zB0I8MMA4pfliXP4dKbvakbyOt8bybuZm71+28tm08i0OAX +jyXLJSD4wGffz5N2X95CUIaW89xOP9Cm3FsV1edDkWrEXNUXPR6vjTsKjbKYO/oqPcaLRlJZR i2KyfbZniLrzvVYuDb8Wh/fp/G5hl9Osj6GSBQe9WjvNz5hYcq7oLcv5pne7g4TfP800wG9Dy7 La8TkDVepoG4KqOq0GbN+w4PbUR4yg36z24KVBX6pVrqmkLdzuioTVYm+wB5H/527X522JTKnE UuSKm2XEUlqUR47oldQK2F6dlCGeWP+ujX3Te+mRzE8yww==; 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=1649608234; bh=YtRAyYZzcjM7bi/7sFEazPnXa6UJMqOp6jGKk/Z7ElQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:MIME-Version:References:Message-ID:In-Reply-To: Date:Reply-To:Subject:To:From:DKIM-Signature:DKIM-Signature; b=pyrR6sfSpwKrfu6lmddKBuf2UHjOypdsPKd1zfmz0RBgk2U+ln4sGEAFnV+MtBqyiz3Kna5ly+ 93Qorwa/XuBY1bM4CPwc8obcBGy7HkqRz/7F3RJ6HgJ7Sam4gvtkYROk2Diu8JN+tBCUrx6mQ/ zMugc3UqhprjnsVr4TH9cvAddb/eZ4qcDnmWW9iL4+58U7/HpHfwD6k6QAoBBmrpGhg+qwYh1k JJIqFbjTZqwskmLMP6TW73FUlYCAILuF0jsKlZKT1d8JjjUj+v0QOCujo0zYzcdFQVw5GMzTa3 UtJiue3GWmVdgTYSMpovH0Nyy6QfaIkrsviX6cFfhvo/7g==; 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-Type:MIME-Version:References: Message-ID:In-Reply-To:Date:Reply-To:Subject:To:From:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=FI+gpKC51dR5CZysrsimNiLDkp5mU8FejNOdTbWJylQ=; b=fMvVu2pd8BFoWGJO2zmDq60HWE DUZOym4mMbON5kPB0AJy18y/5Ck5eeuoB6cmm2/jrl2gYNEZJantflLa+soOpRNIIYV3qdlrjgwrl kL5lX58VSh4N3GYcTvzyx/8zTGLaFPhCB+Th9Q8nJsRw1OhtlXRjw41iJj32OzszdvVaHvcQqDAkf LKBkXh0//VNPj7PZyTfnsfSla9z968UGwnlu0L+blDJBuHhCPXdVbcdjiNAjFRgqPxANdIxXwlWAj PdUpwzsrG0LCG6ufwPgTco+lTxL3Ddutz08eCyqsGN8/Rc5BDaJqTa5PM089BKTBYJsEjXTcVq1BE IwfEBTwA==; Received: from authenticated user by zero.zsh.org with local id 1ndaSQ-000F1z-Rx; Sun, 10 Apr 2022 16:30:34 +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]:31014) by zero.zsh.org with utf8esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1ndaSA-000Egh-Ui; Sun, 10 Apr 2022 16:30:19 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=klanderman.net; q=dns/txt; s=mg; t=1649608218; h=Content-Type: MIME-Version: References: Message-ID: In-Reply-To: Date: Reply-To: Subject: Subject: To: To: From: From: Sender: Sender; bh=FI+gpKC51dR5CZysrsimNiLDkp5mU8FejNOdTbWJylQ=; b=LGrWu2p2VD2qslpkTCB9h/BSW97tTNxtbriVNWcjwsTcwR3UZte6xNV7EseKp2S4kI+QMNZs TfOOTqZbLXnyNM4XcOABDB7eRvgXcZZBpZBCFI8NTYrLSalcudv/zaNH47qYR6mMOwva/Fd/ bFkh5qF236zUKGstzXJ3XAe3UAQ= 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-n03.prod.us-west-2.postgun.com with SMTP id 625306127a6ca2b683d0339f (version=TLS1.3, cipher=TLS_AES_128_GCM_SHA256); Sun, 10 Apr 2022 16:30:10 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 8C7A040E08; Sun, 10 Apr 2022 12:30:08 -0400 (EDT) Received: by lwm.klanderman.net (Postfix, from userid 1000) id 645AF29E0094; Sun, 10 Apr 2022 12:30:08 -0400 (EDT) From: Greg Klanderman To: zsh-workers@zsh.org Subject: Re: using trap function to cleanup and exit? Reply-To: Greg Klanderman Date: Sun, 10 Apr 2022 12:30:08 -0400 In-Reply-To: <87fsmk2a03.fsf@lwm.klanderman.net> (Greg Klanderman's message of "Sun, 10 Apr 2022 12:12:12 -0400") Message-ID: <87czho2967.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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Seq: 50025 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: Is there an equivalent for exiting when using the trap builtin (list traps)? I don't completely understand the manual: | a return from a list trap causes the surrounding context to return | with the given status I've tried both exit and return in a list trap, and am not seeing the script exit. Also, is exit intentionally disabled from within a trap function? I didn't expect that, even with the special return handling. So, there is no way to exit 0 from a trap, since that is interpreted as the signal having been handled, and wanting to continue executing? With no traps of either type, should the child sleep remain after the script is killed by a signal? thank you, Greg >>>>> On April 10, 2022 Greg Klanderman wrote: > Hi Peter, > I thought I'd changed that last night when I was reading that section > of the manual, when I changed the exit value 1 to $(( 128 + $1 )), but > apparently not. > That does seem to be working better, in that the script itself does > exit after running the cleanup, but the child sleep process still > remains. > I am playing with 'kill -9 -$$' in the trap function, but that seems > like an awfully large hammer. > thank you, > Greg >>>>> On April 10, 2022 Peter Stephenson wrote: >> On Sun, 2022-04-10 at 11:46 -0400, Greg Klanderman wrote: >>> TRAPTERM () { >>> echo "in TRAPTERM" >>> cleanup TERM >>> exit $(( 128 + $1 )) >>> } >> I haven't gone through this in great detail, so no guarantee this causes >> everything to spring into life, but just to note that normal service >> here would be obtained if you turn that "exit" into "return". As >> described in the Trap Functions in zshmisc, that's specially handled so >> that the shell knows you want to continue to exit in a similar way to if >> SIGTERM had been received without the trap function. >> pws