From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43566-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 5023a9aa for ; Wed, 26 Sep 2018 15:51:15 +0000 (UTC) Received: (qmail 776 invoked by alias); 26 Sep 2018 15:51:04 -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: List-Unsubscribe: X-Seq: 43566 Received: (qmail 27639 invoked by uid 1010); 26 Sep 2018 15:51:04 -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(-7.3/5.0):. Processed in 2.444133 secs); 26 Sep 2018 15:51:04 -0000 X-Envelope-From: p.stephenson@samsung.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180926155056euoutp02e1fc80be1a1d279b6b966fb521eb03e2~X-fwR0xAd0304903049euoutp02n DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537977056; bh=4XRIEbj4te1IHvx1RlT4fbf3a+rmBwmb9XJQzRtYm6g=; h=Date:From:To:Subject:In-Reply-To:References:From; b=GSstHpxcxP+03thwYh5GGwI4kI9NrrnXsP10RXRpCtIGFnLNwV/1XHRtM7sgzDvCo jmvc8RfzwVFIpD+AHUuIm540NpOtT0MXgHVTjyNGOOrBkwRaxKhIHJ4SYNh3fOV6Tg iQ+hD8VA1t+acv7pjMPNWdTd7BkJUdgRQA2jo4vQ= X-AuditID: cbfec7f5-34dff700000012c6-f7-5babaae0b85f Date: Wed, 26 Sep 2018 16:50:53 +0100 From: Peter Stephenson To: Subject: Re: What's a superjob? In-Reply-To: <1537975883.2212216.1521491576.1CF7021B@webmail.messagingengine.com> Organization: SCSC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPIsWRmVeSWpSXmKPExsWy7djP87oPVq2ONmheK2xxsPkhkwOjx6qD H5gCGKO4bFJSczLLUov07RK4MlqnXWcs6BGs2Nu4h62BcS1vFyMnh4SAicSC1lesXYxcHEIC Kxgl2s+fhHL6mCTO3lvJCOH0Mkm8mP6MCabl0KENUFXLGSVe/73ICle17flpZgjnDKPE9+MX WSCcC4wSL38cA+tnEVCV2P9tEyuIzSZgKDF102xGEFtEQFLiWvNpMFtYQF5i16KfYDanQKDE mktvgXo5OPgFhCQuNNtCnGEvcXTPSbCRvAKCEidnPmEBsZmBWre/nQN2hITAZzaJHY/3MEIU lUlsWHaVGWSOhICLxIZFUHOEJV4d38IOYctI/N85nwmit51RYs2k1+wQTg+jxKajdxghqqwl +m5fZAQZxCygKbF+lz5E2FHiUsciFoj5fBI33gpC3MMnMWnbdKi1vBIdbUIQ1WoSO5q2Mk5g VJ6F5INZSD6YhTB/ASPzKkbx1NLi3PTUYuO81HK94sTc4tK8dL3k/NxNjMBkcPrf8a87GPf9 STrEKMDBqMTDy2G7KlqINbGsuDL3EKMEB7OSCO+dKaujhXhTEiurUovy44tKc1KLDzFKc7Ao ifPyaaVFCwmkJ5akZqemFqQWwWSZODilGhgL5lh9kbQ9uW9Vrz+XMYPe0o53axp5ObO2P1hq qnhvBf+8twzp6798XJTdxS19XqxJovTV3fA447S6uC1ykuLy9oHGZz+rTrq7Uzy+cJJcdsOk WIc2jQVhKf72CcYn5s8X5j+30Wm++zS12Voht2yrrvCcDGO+d/rbA2E/zv3smSEzv7SUaiix FGckGmoxFxUnAgDk7E7NAgMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplkeLIzCtJLcpLzFFi42I5/e/4Pd37q1ZHG/T+lbc42PyQyYHRY9XB D0wBjFF6NkX5pSWpChn5xSW2StGGFkZ6hpYWekYmlnqGxuaxVkamSvp2NimpOZllqUX6dgl6 Ga3TrjMW9AhW7G3cw9bAuJa3i5GTQ0LAROLQoQ2sILaQwFJGid9HcyHiMhKfrnxkh7CFJf5c 62LrYuQCqulmktg7+yArhHOGUeJDxwSozAVGiZbNf9lAWlgEVCX2f9sENpZNwFBi6qbZjCC2 iICkxLXm02C2sIC8xK5FP8FsXgFniQN3j4Gt4xQIlFhz6S0TxNAljBKNcycADeLg4BcQkrjQ bAtxkr3E0T0nmSB6BSVOznzCAmIzC+hInFh1jBnClpfY/nYO8wRG4VlIymYhKZuFpGwBI/Mq RpHU0uLc9NxiI73ixNzi0rx0veT83E2MwKjYduznlh2MXe+CDzEKcDAq8fBy2K6KFmJNLCuu zD3EKMHBrCTCe2fK6mgh3pTEyqrUovz4otKc1OJDjKbAwJjILCWanA+M2LySeENTQ3MLS0Nz Y3NjMwslcd7zBpVRQgLpiSWp2ampBalFMH1MHJxSDYwpm+OXam4tOpzzVHPfhu+phatFrVq8 D10Nilq6Tp7T1vb4+j73XU213M//6/5+f6W4MoDdnXHircSju3szJhgWdOfd4t0snnWwa4n+ L3GbuH3HBWO61edzu8wImrX6YfMslhaOF17MUxnerxOSLdrEamL+0vGk6qzg07/nTUo3LTl1 T/BBELcSS3FGoqEWc1FxIgDYHJ2moAIAAA== Message-Id: <20180926155055eucas1p2a9eeba9267adcb603fbd609e47780010~X-fvU7i_h1255912559eucas1p2q@eucas1p2.samsung.com> X-CMS-MailID: 20180926155055eucas1p2a9eeba9267adcb603fbd609e47780010 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20180926153149epcas3p1a817e8295570aa23ef107f7ecb95f980 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180926153149epcas3p1a817e8295570aa23ef107f7ecb95f980 References: <1537975883.2212216.1521491576.1CF7021B@webmail.messagingengine.com> On Wed, 26 Sep 2018 15:31:23 +0000 Daniel Shahaf wrote: > Could someone explain in a sentence what a 'superjob' is? Not in a sentence, no. > I'm guessing that it's the 'bodyguard shell' demonsrated in > Joey's 43506 and explained in 43514. Is that correct? Yes, basically, if you mean what I think you mean. % e() { vi echo "There might be some more code here, for the sake of example" } % e Now we have just one process running: the main shell, and vi. Suppose you hit ^Z. Then vi suspends. The main shell is in the middle of running e, but it's not supposed to finish doing that till vi exits. But without special action we're now back at the top-level shell prompt and it never will execute. So when it detects this case the shell forks. Now we have two processes apart from the main shell itself: the forked shell is in the superjob, and will eventually finish running the function. The vi process is in the subjob. The superjob may have more than one process if the structure of the code is more complicated e.g. a pipeline that needs to finish only when the subjob is done. Why two different jobs? Because we have two processes separately forked from the main shell. When the subjob exits, the main shell will tell the superjob to carry on, so it will print that echo --- that's why the forked shell is the "super"job, not the other way around, and why we show the superjob to the user rather than the subjob, because it's the longer lived of the two. We are having to jump through hoops because the user has been told there is only the superjob. On % bg both jobs are put into the background, though the forked shell (superjob) will stay suspended for the time being. In this case, the subjob gets SIGTTOU and we now report *this* suspension (we suppress the fact that the superjob's forked shell process is suspended as it's not relevant to what the user thinks is going on). On % fg both jobs are put back into the foreground, but again the forked shell stays suspended. When vi (subjob) exits, the forked shell is woken up and runs the rest of the function. pws