Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make bin/12734: fix SIGTSTP/SIGCONT handling.



details:   https://anonhg.NetBSD.org/src/rev/42dc4e27fa36
branches:  trunk
changeset: 509286:42dc4e27fa36
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Tue May 01 03:27:50 2001 +0000

description:
bin/12734: fix SIGTSTP/SIGCONT handling.

 - install SIGCONT handler which reestablishes SIGTSTP handler and then calls
JobRestartJobs() to restart all the suspended jobs.
 - when SIGTSTP is handled, call JobCatchChildren() so *** Suspended messages
get printed before make stops rather than after.

diffstat:

 usr.bin/make/job.c |  42 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 37 insertions(+), 5 deletions(-)

diffs (97 lines):

diff -r c93039cff29d -r 42dc4e27fa36 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Tue May 01 03:01:18 2001 +0000
+++ b/usr.bin/make/job.c        Tue May 01 03:27:50 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.46 2001/01/10 15:54:00 christos Exp $        */
+/*     $NetBSD: job.c,v 1.47 2001/05/01 03:27:50 sommerfeld Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -39,14 +39,14 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: job.c,v 1.46 2001/01/10 15:54:00 christos Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.47 2001/05/01 03:27:50 sommerfeld 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.46 2001/01/10 15:54:00 christos Exp $");
+__RCSID("$NetBSD: job.c,v 1.47 2001/05/01 03:27:50 sommerfeld Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -308,6 +308,9 @@
 static int JobCondPassSig __P((ClientData, ClientData));
 static void JobPassSig __P((int));
 static void JobIgnoreSig __P((int));
+#ifdef USE_PGRP
+static void JobContinueSig __P((int));
+#endif
 static int JobCmpPid __P((ClientData, ClientData));
 static int JobPrintCommand __P((ClientData, ClientData));
 static int JobSaveCommand __P((ClientData, ClientData));
@@ -398,6 +401,30 @@
 }
 
 
+#ifdef USE_PGRP
+/*-
+ *-----------------------------------------------------------------------
+ * JobContinueSig --
+ *     Resume all stopped jobs.
+ *
+ * Results:
+ *     None.
+ *
+ * Side Effects:
+ *     Jobs start running again.
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+JobContinueSig(signo)
+    int            signo;      /* The signal number we've received */
+{
+    if (signal(SIGTSTP, SIG_IGN) != SIG_IGN) {
+       (void) signal(SIGTSTP, JobPassSig);
+    }
+    JobRestartJobs();
+}
+#endif
 
 /*-
  *-----------------------------------------------------------------------
@@ -445,6 +472,9 @@
        Finish(0);
     }
 
+    if (signo == SIGTSTP) {
+       Job_CatchChildren(FALSE);
+    }
     /*
      * Send ourselves the signal now we've given the message to everyone else.
      * Note we block everything else possible while we're getting the signal.
@@ -460,8 +490,7 @@
 
     if (DEBUG(JOB)) {
        (void) fprintf(stdout,
-                      "JobPassSig passing signal to self, mask = %x.\n",
-                      ~0 & ~(1 << (signo-1)));
+                      "JobPassSig passing signal %d to self.\n", signo);
        (void) fflush(stdout);
     }
 
@@ -2562,6 +2591,9 @@
     if (signal(SIGWINCH, SIG_IGN) != SIG_IGN) {
        (void) signal(SIGWINCH, JobPassSig);
     }
+    if (signal(SIGCONT, SIG_IGN) != SIG_IGN) {
+       (void) signal(SIGCONT, JobContinueSig);
+    }
 #endif
 
     begin = Targ_FindNode(".BEGIN", TARG_NOCREATE);



Home | Main Index | Thread Index | Old Index