about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-08-31 13:55:45 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-08-31 13:55:45 +0000
commitced33358fcbeb9e469927a63c33d73acc1db5c32 (patch)
tree3dd13ff6628cd65eba064ba95d788449926b09a8
parent8e5365152aa58bb0d8a209efe176e1e7ae70675f (diff)
downloadzsh-ced33358fcbeb9e469927a63c33d73acc1db5c32.tar.gz
zsh-ced33358fcbeb9e469927a63c33d73acc1db5c32.tar.xz
zsh-ced33358fcbeb9e469927a63c33d73acc1db5c32.zip
zsh-workers/7573
-rw-r--r--Src/exec.c7
-rw-r--r--Src/signals.c36
-rw-r--r--Src/utils.c2
3 files changed, 37 insertions, 8 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 97e8f4912..2fb3b5e9b 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1760,6 +1760,13 @@ execcmd(Cmd cmd, int input, int output, int how, int last1)
 #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 &&
diff --git a/Src/signals.c b/Src/signals.c
index 71fac245d..94cf1099f 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -592,22 +592,44 @@ killjb(Job jn, int sig)
             if (sig == SIGCONT) {
                 for (pn = jobtab[jn->other].procs; pn; pn = pn->next)
                     if (killpg(pn->pid, sig) == -1)
-			kill(pn->pid, sig);
+			if (kill(pn->pid, sig) == -1 && errno != ESRCH)
+#ifdef BROKEN_KILL_ESRCH
+			    if(errno != EINVAL || sig != 0)
+#endif /* BROKEN_KILL_ESRCH */
+				err = -1;
  
                 for (pn = jn->procs; pn->next; pn = pn->next)
-                    err = kill(pn->pid, sig);
+                    if (kill(pn->pid, sig) == -1 && errno != ESRCH)
+#ifdef BROKEN_KILL_ESRCH
+			if(errno != EINVAL || sig != 0)
+#endif /* BROKEN_KILL_ESRCH */
+			    err = -1;
 
 		if (!jobtab[jn->other].procs && pn)
-		    err = kill(pn->pid, sig);
+		    if (kill(pn->pid, sig) == -1 && errno != ESRCH)
+#ifdef BROKEN_KILL_ESRCH
+			if(errno != EINVAL || sig != 0)
+#endif /* BROKEN_KILL_ESRCH */
+			    err = -1;
 
                 return err;
             }
- 
-            killpg(jobtab[jn->other].gleader, sig);
-            return killpg(jn->gleader, sig);
+            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;
+		
+	    if (killpg(jn->gleader, sig) == -1 && errno != ESRCH)
+#ifdef BROKEN_KILL_ESRCH
+		if(errno != EINVAL || sig != 0)
+#endif /* BROKEN_KILL_ESRCH */
+		    err = -1;
+
+	    return err;
         }
         else
-            return (killpg(jn->gleader, sig));
+	    return killpg(jn->gleader, sig);
     }
     for (pn = jn->procs; pn; pn = pn->next)
         if ((err = kill(pn->pid, sig)) == -1 && errno != ESRCH)
diff --git a/Src/utils.c b/Src/utils.c
index b982b4767..a6fa5f0b0 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -2438,7 +2438,7 @@ attachtty(pid_t pgrp)
 # endif
 #endif
 	{
-	    if (pgrp != mypgrp && kill(pgrp, 0) == -1)
+	    if (pgrp != mypgrp && kill(-pgrp, 0) == -1)
 		attachtty(mypgrp);
 	    else {
 		if (errno != ENOTTY)