Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Make compat.c handle SIGINT etc more like job.c



details:   https://anonhg.NetBSD.org/src/rev/6a680fba8f8a
branches:  trunk
changeset: 825541:6a680fba8f8a
user:      sjg <sjg%NetBSD.org@localhost>
date:      Thu Jul 20 19:29:54 2017 +0000

description:
Make compat.c handle SIGINT etc more like job.c

If there is a running child, pass the signal on, and
wait for it to exit before we self-terminate.

Reviewed by: christos

diffstat:

 usr.bin/make/compat.c |  30 +++++++++++++++++++++++-------
 usr.bin/make/job.c    |  11 +++--------
 usr.bin/make/make.h   |   8 +++++++-
 3 files changed, 33 insertions(+), 16 deletions(-)

diffs (136 lines):

diff -r 80158f115911 -r 6a680fba8f8a usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Thu Jul 20 18:17:25 2017 +0000
+++ b/usr.bin/make/compat.c     Thu Jul 20 19:29:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.106 2016/08/26 23:28:39 dholland Exp $    */
+/*     $NetBSD: compat.c,v 1.107 2017/07/20 19:29:54 sjg Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.106 2016/08/26 23:28:39 dholland Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.107 2017/07/20 19:29:54 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c   8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.106 2016/08/26 23:28:39 dholland Exp $");
+__RCSID("$NetBSD: compat.c,v 1.107 2017/07/20 19:29:54 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -115,6 +115,8 @@
 static GNode       *curTarg = NULL;
 static GNode       *ENDNode;
 static void CompatInterrupt(int);
+static pid_t compatChild;
+static int compatSigno;
 
 /*
  * CompatDeleteTarget -- delete a failed, interrupted, or otherwise
@@ -173,8 +175,17 @@
     }
     if (signo == SIGQUIT)
        _exit(signo);
-    bmake_signal(signo, SIG_DFL);
-    kill(myPid, signo);
+    /*
+     * If there is a child running, pass the signal on
+     * we will exist after it has exited.
+     */
+    compatSigno = signo;
+    if (compatChild > 0) {
+       KILLPG(compatChild, signo);
+    } else {
+       bmake_signal(signo, SIG_DFL);
+       kill(myPid, signo);
+    }
 }
 
 /*-
@@ -367,7 +378,7 @@
     /*
      * Fork and execute the single command. If the fork fails, we abort.
      */
-    cpid = vFork();
+    compatChild = cpid = vFork();
     if (cpid < 0) {
        Fatal("Could not fork");
     }
@@ -480,7 +491,12 @@
        }
     }
     free(cmdStart);
-
+    compatChild = 0;
+    if (compatSigno) {
+       bmake_signal(compatSigno, SIG_DFL);
+       kill(myPid, compatSigno);
+    }
+    
     return (status);
 }
 
diff -r 80158f115911 -r 6a680fba8f8a usr.bin/make/job.c
--- a/usr.bin/make/job.c        Thu Jul 20 18:17:25 2017 +0000
+++ b/usr.bin/make/job.c        Thu Jul 20 19:29:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $      */
+/*     $NetBSD: job.c,v 1.191 2017/07/20 19:29:54 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.191 2017/07/20 19:29:54 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c      8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $");
+__RCSID("$NetBSD: job.c,v 1.191 2017/07/20 19:29:54 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -335,11 +335,6 @@
            (void)fprintf(fp, TARG_FMT, targPrefix, gn->name)
 
 static sigset_t caught_signals;        /* Set of signals we handle */
-#if defined(SYSV)
-#define KILLPG(pid, sig)       kill(-(pid), (sig))
-#else
-#define KILLPG(pid, sig)       killpg((pid), (sig))
-#endif
 
 static void JobChildSig(int);
 static void JobContinueSig(int);
diff -r 80158f115911 -r 6a680fba8f8a usr.bin/make/make.h
--- a/usr.bin/make/make.h       Thu Jul 20 18:17:25 2017 +0000
+++ b/usr.bin/make/make.h       Thu Jul 20 19:29:54 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.102 2016/12/07 15:00:46 christos Exp $      */
+/*     $NetBSD: make.h,v 1.103 2017/07/20 19:29:54 sjg Exp $   */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -525,4 +525,10 @@
 #define PATH_MAX       MAXPATHLEN
 #endif
 
+#if defined(SYSV)
+#define KILLPG(pid, sig)       kill(-(pid), (sig))
+#else
+#define KILLPG(pid, sig)       killpg((pid), (sig))
+#endif
+
 #endif /* _MAKE_H_ */



Home | Main Index | Thread Index | Old Index