From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24243 invoked by alias); 12 Sep 2017 10:19:18 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41679 Received: (qmail 5708 invoked by uid 1010); 12 Sep 2017 10:19:18 -0000 X-Qmail-Scanner-Diagnostics: from mailout2.w1.samsung.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(210.118.77.12):SA:0(-6.9/5.0):. Processed in 2.013402 secs); 12 Sep 2017 10:19:18 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: p.stephenson@samsung.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-AuditID: cbfec7f5-f79d06d0000031c7-dd-59b7b49d7045 Date: Tue, 12 Sep 2017 11:19:06 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: [BUG] exec + builtin and traps Message-id: <20170912111906.397cffec@pwslap01u.europe.root.pri> In-reply-to: <20170912100257.GA32535@zira.vinc17.org> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDIsWRmVeSWpSXmKPExsWy7djP87pzt2yPNPjfZ2lxsPkhkwOjx6qD H5gCGKO4bFJSczLLUov07RK4Mhq2eBSs4Klovn6JqYHx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PE vuPeIDa/gL7E1b+fmCCus5eYeeUM2EheAUGJH5PvgY1kFtCS2LytiRXClpfYvOYtM8QcdYkb d3ezT2AUnoWkZRaSlllIWhYwMq9iFEktLc5Nzy021CtOzC0uzUvXS87P3cQIDORtx35u3sF4 aWPwIUYBDkYlHl6N7m2RQqyJZcWVuYcYJTiYlUR4X6zdHinEm5JYWZValB9fVJqTWnyIUZqD RUmct3fP6kghgfTEktTs1NSC1CKYLBMHp1QDY1vQFfHKuaz+IvsXOtYLTi95uml12IoviXGs DRsc1qq0rF/z5s/sI5LP+efs21vcs2rX6eX6gQ7vppfGGlqfNE+Vu/M2UmjuGqf+WEWp69Z/ 2L2DF3unndG9lr/3n+oTrwOq4aI/rmVnfXi5IynrxSKDFv49s13/ZmYZbPluYTBj3Tl9DfsK DiWW4oxEQy3mouJEAEQGSQdgAgAA X-CMS-MailID: 20170912101909eucas1p182c2574fefaf954d6158f0d6274ea51b X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?UGV0ZXIgU3RlcGhlbnNvbhtTQ1NDLURhdGEgUGxhbmUb?= =?UTF-8?B?7IK87ISx7KCE7J6QG1ByaW5jaXBhbCBFbmdpbmVlciwgU29mdHdhcmU=?= X-Global-Sender: =?UTF-8?B?UGV0ZXIgU3RlcGhlbnNvbhtTQ1NDLURhdGEgUGxhbmUbU2Ft?= =?UTF-8?B?c3VuZyBFbGVjdHJvbmljcxtQcmluY2lwYWwgRW5naW5lZXIsIFNvZnR3YXJl?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDA1Q0QwNTAwNTg=?= CMS-TYPE: 201P X-CMS-RootMailID: 20170912101045epcas2p4cae7e7df78ef035900f9c6099dc054fb X-RootMTR: 20170912101045epcas2p4cae7e7df78ef035900f9c6099dc054fb References: <20170912100257.GA32535@zira.vinc17.org> On Tue, 12 Sep 2017 12:02:57 +0200 Vincent Lefevre wrote: > For zsh 5.4.1, the zshbuiltins(1) man page says: > > exec [ -cl ] [ -a argv0 ] [ command [ arg ... ] ] > Replace the current shell with command rather than forking. > If command is a shell builtin command or a shell function, > the shell executes it, then immediately exits. It means immediately after the command has finished executing, not while it's executing. > #!/usr/bin/env zsh > > trap 'echo foo' USR1 > > echo $$ > ( sleep 1; kill -USR1 $$ ) & > exec eval sleep 2 So in your case it's still exectuing the eval sleep 2. I don't actually understand your interpretation --- given eval is a builtin and the eval is going to take 2 seconds because it dispatches to a sleep, how could the shell exit before that? pws diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index 3afe990..d6aa078 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -669,7 +669,7 @@ an empty string or whitespace) the return status is zero. item(tt(exec) [ tt(-cl) ] [ tt(-a) var(argv0) ] [ var(command) [ var(arg) ... ] ])( Replace the current shell with var(command) rather than forking. If var(command) is a shell builtin command or a shell function, -the shell executes it, then immediately exits. +the shell executes it, and exits when the command is complete. With tt(-c) clear the environment; with tt(-l) prepend tt(-) to the tt(argv[0]) string of the command executed (to simulate a login shell);