zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: loop killing
Date: Thu, 24 Jun 1999 13:55:04 +0200 (MET DST)	[thread overview]
Message-ID: <199906241155.NAA00996@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Peter Stephenson's message of Thu, 24 Jun 1999 11:00:53 +0200


Peter Stephenson wrote:

> Sven Wischnowsky wrote:
> > This is the solution which executes commands in a loop in the same
> > process group as the parent shell.
> 
> This seems to be the neatest solution, covering most of the common things
> you want to do without any fuss.  But at the moment something nasty is
> happening with shell functions.
> 
> % fn() { less $*; }
> % fn glob.c
> ^Z
> <job disappears completely>

execshfunc() deleted the job before the function was executed,
stealing us the information about it. I'm not too sure about the test
I changed this to... (but it seems to work).

> Hmmm, that didn't seem to be working properly even before, except the
> problem then was that when I tried to continue it I got the message 
>   zsh: 39221 suspended (tty output)  l glob.c
> so it looks like the process groups were already getting messed up.
> So maybe the new problem is just the old one appearing in a different
> place.

Right. The sub-shell for the shell (the super-job) put itself
unconditionally into the group of the gleader of the list_pipe_job --
but in cases like this one the sub-shell itself is the first job that
is entered into it, so gleader wasn't set and the sub-shell ended in
its own little process group which gave us the problem above when the
parent shell tried to foreground the job and used gleader of the
super-job for that.

Bye
 Sven

diff -u os/exec.c Src/exec.c
--- os/exec.c	Thu Jun 24 11:47:25 1999
+++ Src/exec.c	Thu Jun 24 13:40:28 1999
@@ -901,6 +901,9 @@
 		    DPUTS(!list_pipe_pid, "invalid list_pipe_pid");
 		    addproc(list_pipe_pid, list_pipe_text);
 
+		    if (!jn->procs->next)
+			jn->gleader = mypgrp;
+
 		    for (pn = jobtab[jn->other].procs; pn; pn = pn->next)
 			if (WIFSTOPPED(pn->status))
 			    break;
@@ -977,11 +980,13 @@
 		    else {
 			close(synch[0]);
 			entersubsh(Z_ASYNC, 0, 0);
-			setpgrp(0L, mypgrp = jobtab[list_pipe_job].gleader);
+			if (jobtab[list_pipe_job].procs)
+			    setpgrp(0L, mypgrp = jobtab[list_pipe_job].gleader);
 			close(synch[1]);
 			kill(getpid(), SIGSTOP);
 			list_pipe = 0;
 			list_pipe_child = 1;
+			opts[INTERACTIVE] = 0;
 			break;
 		    }
 		}
@@ -2793,14 +2798,13 @@
     if (errflag)
 	return;
 
-    if (!list_pipe) {
+    if (!list_pipe && thisjob != list_pipe_job) {
 	/* Without this deletejob the process table *
 	 * would be filled by a recursive function. */
 	last_file_list = jobtab[thisjob].filelist;
 	jobtab[thisjob].filelist = NULL;
 	deletejob(jobtab + thisjob);
     }
-
     if (isset(XTRACE)) {
 	LinkNode lptr;
 	printprompt4();
diff -u os/signals.c Src/signals.c
--- os/signals.c	Thu Jun 24 11:47:28 1999
+++ Src/signals.c	Thu Jun 24 13:44:36 1999
@@ -584,7 +584,7 @@
                 for (pn = jobtab[jn->other].procs; pn; pn = pn->next)
                     kill(pn->pid, sig);
  
-                for (pn = jn->procs; pn; pn = pn->next)
+                for (pn = jn->procs; pn->next; pn = pn->next)
                     err = kill(pn->pid, sig);
  
                 return err;

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


             reply	other threads:[~1999-06-24 11:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-24 11:55 Sven Wischnowsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-06-25 14:21 Sven Wischnowsky
1999-06-25 15:00 ` Andrej Borsenkow
1999-06-25 16:23   ` Andrej Borsenkow
1999-06-25 16:29     ` Peter Stephenson
1999-06-24  9:08 Sven Wischnowsky
1999-06-24  9:00 ` Peter Stephenson
1999-06-25 13:21 ` Andrej Borsenkow

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=199906241155.NAA00996@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /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).