zsh-workers
 help / color / mirror / code / Atom feed
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:42:00 -0700	[thread overview]
Message-ID: <CAH+w=7ZyUS0F+74t0wrD-vKJiDWt0QypsRQGaS1njRiLTscZHg@mail.gmail.com> (raw)
In-Reply-To: <20180926155055eucas1p2a9eeba9267adcb603fbd609e47780010~X-fvU7i_h1255912559eucas1p2q@eucas1p2.samsung.com>

On Wed, Sep 26, 2018 at 8:51 AM Peter Stephenson
<p.stephenson@samsung.com> wrote:
>
> 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.

To add a bit more color here ... in the absence of this special
handling, when vi is suspended, the shell has two choices:
1) treat vi as successfully completed and continue executing the function, or
2) treat vi as failed and stop the function at this point.

IIRC different shells have historically made different decisions about
this.  I believe zsh's original behavior was #1, but that led to
problems if (in this type of example) the remainder of the function
depends on the content of the edited file.  So #2 avoids side-effects,
but causes at minimum annoyance because now you have a suspended vi
but the rest of the function is simply gone.

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.

  reply	other threads:[~2018-09-26 17:42 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 [this message]
2018-09-26 17:52       ` Bart Schaefer
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=7ZyUS0F+74t0wrD-vKJiDWt0QypsRQGaS1njRiLTscZHg@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).