From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21298 invoked from network); 1 Sep 1999 12:11:27 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 1 Sep 1999 12:11:27 -0000 Received: (qmail 15859 invoked by alias); 1 Sep 1999 12:11:12 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7605 Received: (qmail 15852 invoked from network); 1 Sep 1999 12:11:12 -0000 Date: Wed, 1 Sep 1999 14:11:09 +0200 (MET DST) Message-Id: <199909011211.OAA00620@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Sven Wischnowsky's message of Wed, 1 Sep 1999 10:08:37 +0200 (MET DST) Subject: 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@informatik.hu-berlin.de