zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: prob: fg not sending CONT to 'make' children
Date: Wed, 1 Sep 1999 14:11:09 +0200 (MET DST)	[thread overview]
Message-ID: <199909011211.OAA00620@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Sven Wischnowsky's message of Wed, 1 Sep 1999 10:08:37 +0200 (MET DST)


I wrote:

> (Damn. After thinking again: there is a problem with `a | b | c' if `b' 
> is started when `a' still lives and `c' is started when `a' is dead.
> I'll have to look at it again. Sigh.)
> 
> The problem is in `entersubsh()' where we use `kill(..)' to test if a
> forked process has to put itself in its own process group. I tried
> to change this to `killpg(..)' and it fixed the problem with `a | b'
> where `b' is a command. But it also made that fail if `b' is a shell
> construct (or function). There is some code elsewhere which makes this 
> work with the `kill(..)' for pipes ending in shell constructs -- I
> have to find that place again to make it work with normal pipes, too.

The problem was only in bin_fg(), it seems where it checked if the
leader was dead and then attached the tty to the sub-job's leader.

So this patch removes the nasty the-leader-is-dead-long-live-the-leader
and instead uses the killpg() in entersubsh(). Then it changes the
test in bin_fg().

Bye
 Sven

diff -u os/exec.c Src/exec.c
--- os/exec.c	Wed Sep  1 11:59:38 1999
+++ Src/exec.c	Wed Sep  1 14:05:52 1999
@@ -1760,13 +1760,6 @@
 #ifdef PATH_DEV_FD
 	    closem(2);
 #endif
-
-	    /* If there is already a group leader but that has died, we make
-	     * this one the leader. */
-	    if (pline_level == 1 && jobtab[thisjob].procs &&
-		kill(jobtab[thisjob].gleader, 0) == -1)
-		jobtab[thisjob].gleader = pid;
-
 	    if (how & Z_ASYNC) {
 		lastpid = (zlong) pid;
 	    } else if (!jobtab[thisjob].stty_in_env &&
@@ -2242,7 +2235,7 @@
 	}
     } else if (thisjob != -1 && cl) {
 	if (jobtab[list_pipe_job].gleader && (list_pipe || list_pipe_child)) {
-	    if (kill(jobtab[list_pipe_job].gleader, 0) == -1 ||
+	    if (killpg(jobtab[list_pipe_job].gleader, 0) == -1 ||
 		setpgrp(0L, jobtab[list_pipe_job].gleader) == -1) {
 		jobtab[list_pipe_job].gleader =
 		    jobtab[thisjob].gleader = (list_pipe_child ? mypgrp : getpid());
diff -u os/jobs.c Src/jobs.c
--- os/jobs.c	Wed Sep  1 11:59:38 1999
+++ Src/jobs.c	Wed Sep  1 14:05:41 1999
@@ -1292,8 +1292,7 @@
 		    thisjob = job;
 		    if ((jobtab[job].stat & STAT_SUPERJOB) &&
 			((!jobtab[job].procs->next ||
-			  WIFEXITED(jobtab[job].procs->status) ||
-			  WIFSIGNALED(jobtab[job].procs->status))) &&
+			  killpg(jobtab[job].gleader, 0) == -1)) &&
 			jobtab[jobtab[job].other].gleader)
 			attachtty(jobtab[jobtab[job].other].gleader);
 		    else

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


             reply	other threads:[~1999-09-01 12:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-01 12:11 Sven Wischnowsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-09-01  8:08 Sven Wischnowsky
1999-09-01 16:46 ` Bart Schaefer
1999-08-31 11:25 Sven Wischnowsky
1999-08-31 16:40 ` Bart Schaefer
1999-08-30  8:21 Sven Wischnowsky
1999-08-30 14:43 ` Bart Schaefer
1999-08-29  7:35 Will Day
1999-08-29 18:42 ` Bart Schaefer

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=199909011211.OAA00620@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).