zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: Re: prob: fg not sending CONT to 'make' children
Date: Tue, 31 Aug 1999 16:40:22 +0000	[thread overview]
Message-ID: <990831164023.ZM16987@candle.brasslantern.com> (raw)
In-Reply-To: <199908311125.NAA29655@beta.informatik.hu-berlin.de>

On Aug 31,  1:25pm, Sven Wischnowsky wrote:
} Subject: Re: prob: fg not sending CONT to 'make' children
}
} The patch below makes the return value be -1 if at least one of the
} kill()s failed.

Really?  It doesn't look to me as though it changes that behavior at all.
And all those #ifdefs make it really hard to read, and testing sig != 0 is
redundant because the whole thing is inside "if (sig == SIGCONT) ...".

} NOTE: while playing with this I found a bug when I did `ls|sleep 800'
} where the `ls' finished before the `sleep' process was set up -- the
} `sleep' put itself in its own little process group and one couldn't fg 
} the whole thing. I tried several ways to fix this now and the hunks in 
} `exec.c' and `utils.c' are the only ones which made this work

That's very odd.  I didn't think the PID passed to killpg() should change
if you still want to signal the whole group, even if the group leader had
exited.  I wonder what happens if there are more than two processes in
the group when the leader exits?  Do all the leader's children become
their own little leaders?

Hmm, this is something I used to know, about 12 years ago ...

Index: Src/jobs.c
===================================================================
@@ -835,11 +835,7 @@
 
     /* child_block() around this loop in case #ifndef WNOHANG */
     child_block();		/* unblocked in child_suspend() */
-#ifdef BROKEN_KILL_ESRCH
-    while (!errflag && (kill(pid, 0) >= 0 || (errno != ESRCH && errno != EINVAL))) {
-#else /* not BROKEN_KILL_ESRCH */
     while (!errflag && (kill(pid, 0) >= 0 || errno != ESRCH)) {
-#endif /* BROKEN_KILL_ESRCH */
 	if (first)
 	    first = 0;
 	else
Index: Src/signals.c
===================================================================
@@ -593,38 +593,23 @@
                 for (pn = jobtab[jn->other].procs; pn; pn = pn->next)
                     if (killpg(pn->pid, sig) == -1)
 			if (kill(pn->pid, sig) == -1 && errno != ESRCH)
-#ifdef BROKEN_KILL_ESRCH
-			    if(errno != EINVAL || sig != 0)
-#endif /* BROKEN_KILL_ESRCH */
-				err = -1;
+			    err |= -1;
  
                 for (pn = jn->procs; pn->next; pn = pn->next)
                     if (kill(pn->pid, sig) == -1 && errno != ESRCH)
-#ifdef BROKEN_KILL_ESRCH
-			if(errno != EINVAL || sig != 0)
-#endif /* BROKEN_KILL_ESRCH */
-			    err = -1;
+			err |= -1;
 
 		if (!jobtab[jn->other].procs && pn)
 		    if (kill(pn->pid, sig) == -1 && errno != ESRCH)
-#ifdef BROKEN_KILL_ESRCH
-			if(errno != EINVAL || sig != 0)
-#endif /* BROKEN_KILL_ESRCH */
-			    err = -1;
+			err |= -1;
 
                 return err;
             }
             if (killpg(jobtab[jn->other].gleader, sig) == -1 && errno != ESRCH)
-#ifdef BROKEN_KILL_ESRCH
-		if(errno != EINVAL || sig != 0)
-#endif /* BROKEN_KILL_ESRCH */
-		    err = -1;
+		err = -1;
 		
 	    if (killpg(jn->gleader, sig) == -1 && errno != ESRCH)
-#ifdef BROKEN_KILL_ESRCH
-		if(errno != EINVAL || sig != 0)
-#endif /* BROKEN_KILL_ESRCH */
-		    err = -1;
+		err |= -1;
 
 	    return err;
         }
@@ -632,10 +617,7 @@
 	    return killpg(jn->gleader, sig);
     }
     for (pn = jn->procs; pn; pn = pn->next)
-        if ((err = kill(pn->pid, sig)) == -1 && errno != ESRCH)
-#ifdef BROKEN_KILL_ESRCH
-          if(errno != EINVAL || sig != 0)
-#endif /* BROKEN_KILL_ESRCH */
+        if ((err = kill(pn->pid, sig)) == -1 && errno != ESRCH && sig != 0)
             return -1;
     return err;
 }
Index: Src/system.h
===================================================================
@@ -620,3 +620,8 @@
 #ifdef BROKEN_TCSETPGRP
 #undef JOB_CONTROL
 #endif /* BROKEN_TCSETPGRP */
+
+#ifdef BROKEN_KILL_ESRCH
+#undef ESRCH
+#define ESRCH EINVAL
+#endif /* BROKEN_KILL_ESRCH */

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1999-08-31 17:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-31 11:25 Sven Wischnowsky
1999-08-31 16:40 ` Bart Schaefer [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-09-01 12:11 Sven Wischnowsky
1999-09-01  8:08 Sven Wischnowsky
1999-09-01 16:46 ` 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=990831164023.ZM16987@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --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).