Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: prob: fg not sending CONT to 'make' children



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@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author