zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: interrupt handling bug (again?)
Date: Fri, 30 Jun 2017 22:16:10 +0100	[thread overview]
Message-ID: <20170630221610.442726ab@ntlworld.com> (raw)
In-Reply-To: <20170630143347.7f1c252c@pwslap01u.europe.root.pri>

On Fri, 30 Jun 2017 14:33:47 +0100
Peter Stephenson <p.stephenson@samsung.com> wrote:

> On Sat, 24 Jun 2017 12:03:10 -0700
> Bart Schaefer <schaefer@brasslantern.com> wrote:
> 
> > On Jun 6,  9:08pm, Mikael Magnusson wrote:
> > }
> > } % for a in 1 2 3; do xterm; done
> > } then hit ctrl-z in that term and bg it, do stuff and at some point hit
> > } ctrl-c, the backgrounded for loop will be interrupted
> > ...if you interrupt before the foreground job is done, the
> > parent faithfully propagates the signal to the entry in the job
> > table, and that kills the loop when it finally does restart.
> 
> I think that is happening, but I'm not sure where.

It's check_cursh_sig(SIGINT) from the interrupt handler.  It propagates
to jobs marked as STAT_CURSH.

I think when the SUPERJOB is put into the background it should no longer
have STAT_CURSH status.  Does that sound reasonable?  I'm not sure why
it would have it anyway, should it perhaps be removed when we mark it as
STAT_SUPERJOB, which is kind of decurrentshellising it in any case?

Anyway, this minimal fix seems to do the right thing for the case in
question.  It might have side effects, though.  More specificaly, if it
didn't have side effects that would be some kind of record.

pws

diff --git a/Src/jobs.c b/Src/jobs.c
index d1b98ac..09a8bab 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -2303,6 +2303,7 @@ bin_fg(char *name, char **argv, Options ops, int func)
 			}
 			pn = next;
 		    }
+		    jobtab[job].stat &= ~STAT_CURSH;
 		}
 	    } else if (func == BIN_BG) {
 		/* Silly to bg a job already running. */


  reply	other threads:[~2017-06-30 21:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06 19:08 Mikael Magnusson
2017-06-24 19:03 ` Bart Schaefer
2017-06-30 13:33   ` Peter Stephenson
2017-06-30 21:16     ` Peter Stephenson [this message]
2017-07-02 19:32       ` Peter Stephenson
2017-07-02 20:05         ` Bart Schaefer
2017-07-02 20:22           ` Peter Stephenson
2017-07-03 15:09   ` Peter Stephenson
2017-07-10  9:36     ` Peter Stephenson

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=20170630221610.442726ab@ntlworld.com \
    --to=p.w.stephenson@ntlworld.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).