From: Bart Schaefer <schaefer@brasslantern.com>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: What's a superjob?
Date: Wed, 26 Sep 2018 10:52:39 -0700 [thread overview]
Message-ID: <CAH+w=7Y+NdvRvoYQhZ4Z_UxOjMv+RMea5ovk2Z3nETg6-V3QQg@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7ZyUS0F+74t0wrD-vKJiDWt0QypsRQGaS1njRiLTscZHg@mail.gmail.com>
On Wed, Sep 26, 2018 at 10:42 AM Bart Schaefer
<schaefer@brasslantern.com> 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.
next prev parent reply other threads:[~2018-09-26 17:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20180926153149epcas3p1a817e8295570aa23ef107f7ecb95f980@epcas3p1.samsung.com>
2018-09-26 15:31 ` Daniel Shahaf
2018-09-26 15:50 ` Peter Stephenson
2018-09-26 17:42 ` Bart Schaefer
2018-09-26 17:52 ` Bart Schaefer [this message]
2018-09-27 15:51 ` [PATCH] Start documenting jobs.c, in particular superjobs Daniel Shahaf
2018-09-28 15:06 ` What's a superjob? Vincent Lefevre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH+w=7Y+NdvRvoYQhZ4Z_UxOjMv+RMea5ovk2Z3nETg6-V3QQg@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).