Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: What's a superjob?
- X-seq: zsh-workers 43568
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: What's a superjob?
- Date: Wed, 26 Sep 2018 10:52:39 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Nc77/0VKnedOI3x9aOeCjkbEet82gp6pHfDjxLl2jcI=; b=TttL75Aq/lr2iM7fJ1tL3YthN30JA4uMi8Re/gHZi/Rr6T8DN6qeNXo7wA4/kTaLV/ hmZUAREbnRAUtJynBFS+ytJXl0TPvtXNvWXlEyyHPnHyiLXeyjf24QomcvxFlm6BZiOL JinWNzXI61aK9wZmg+ChgBBQD5QpILZ1b4mr9JaiG9wFGluXNIXHz7RsgN3/JhSN8F0H UycY7PWNbk8psTpt5zkjt9mxUP1tehZp826EYcmLk8gncUNF90ggwVsFKhrf6+43mkZ/ 7YD3giew/qeGTVQy8Zya7TdaV38FFIWfqdbrTQwBtk7ucjr/zNhqMm7bLQ3geoSxU9+k mIGQ==
- In-reply-to: <CAH+w=7ZyUS0F+74t0wrD-vKJiDWt0QypsRQGaS1njRiLTscZHg@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20180926153149epcas3p1a817e8295570aa23ef107f7ecb95f980@epcas3p1.samsung.com> <1537975883.2212216.1521491576.1CF7021B@webmail.messagingengine.com> <20180926155055eucas1p2a9eeba9267adcb603fbd609e47780010~X-fvU7i_h1255912559eucas1p2q@eucas1p2.samsung.com> <CAH+w=7ZyUS0F+74t0wrD-vKJiDWt0QypsRQGaS1njRiLTscZHg@mail.gmail.com>
On Wed, Sep 26, 2018 at 10:42 AM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> The other possibility is to immediately fork the whole function as
> soon as any non-builtin command is encountered, and then have the
> forked function fork again for the external job, to keep the process
> tree "normal". This would simplify the job handling in the main
> shell, but ruin the intention of the function being able to affect the
> main shell context in the case where no job control ever occurs.
Hmm, now that Peter has already finished his juggling act, caught all
the clubs, and taken a bow, this suggestion may be moot, but:
Another possibility would be to always fork twice for any external job
inside a current shell construct, so we immediately end up with this:
zsh[parent] -> zsh[superjob] -> vi[subjob]
* If subjob exits normally, so does the superjob; parent continues on
with the function/brace expression/loop/whatever.
* However, if subjob is suspended, superjob is also suspended and
changes its state such that when subjob finally exits, superjob
continues with whatever.
* In parent, if superjob is suspended, the rest of the construct is
abandoned (because we know superjob will finish it).
This wastes a fork if job control never happens, but it means the
parent only has to manage one job at a time. The extra fork could be
skipped if job control is disabled.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author