Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Fix extreme brokeness with job control that app...
details: https://anonhg.NetBSD.org/src/rev/40abab3a376c
branches: trunk
changeset: 474690:40abab3a376c
user: christos <christos%NetBSD.org@localhost>
date: Fri Jul 16 05:38:20 1999 +0000
description:
Fix extreme brokeness with job control that appeared when we set USE_PGRP.
diffstat:
usr.bin/make/job.c | 86 ++++++++++++++++++++++++++++-------------------------
1 files changed, 46 insertions(+), 40 deletions(-)
diffs (222 lines):
diff -r e67eacd6d7d3 -r 40abab3a376c usr.bin/make/job.c
--- a/usr.bin/make/job.c Fri Jul 16 01:38:20 1999 +0000
+++ b/usr.bin/make/job.c Fri Jul 16 05:38:20 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.27 1999/07/06 14:02:56 christos Exp $ */
+/* $NetBSD: job.c,v 1.28 1999/07/16 05:38:20 christos 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.27 1999/07/06 14:02:56 christos Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.28 1999/07/16 05:38:20 christos 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.27 1999/07/06 14:02:56 christos Exp $");
+__RCSID("$NetBSD: job.c,v 1.28 1999/07/16 05:38:20 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -289,19 +289,12 @@
* stuff much more. So, we devise our own macros... This is
* really ugly, use dramamine sparingly. You have been warned.
*/
-#define W_SETMASKED(st, val, fun) \
- { \
- int sh = (int) ~0; \
- int mask = fun(sh); \
- \
- for (sh = 0; ((mask >> sh) & 1) == 0; sh++) \
- continue; \
- *(st) = (*(st) & ~mask) | ((val) << sh); \
- }
-
-#define W_SETTERMSIG(st, val) W_SETMASKED(st, val, WTERMSIG)
-#define W_SETEXITSTATUS(st, val) W_SETMASKED(st, val, WEXITSTATUS)
-
+#ifndef W_STOPCODE
+#define W_STOPCODE(sig) (((sig) << 8) | 0177)
+#endif
+#ifndef W_EXITCODE
+#define W_EXITCODE(ret, sig) ((ret << 8) | (sig))
+#endif
static int JobCondPassSig __P((ClientData, ClientData));
static void JobPassSig __P((int));
@@ -390,6 +383,7 @@
{
sigset_t nmask, omask;
struct sigaction act;
+ int sigcont;
if (DEBUG(JOB)) {
(void) fprintf(stdout, "JobPassSig(%d) called.\n", signo);
@@ -421,8 +415,7 @@
* This ensures that all our jobs get continued when we wake up before
* we take any other signal.
*/
- sigemptyset(&nmask);
- sigaddset(&nmask, signo);
+ sigfillset(&nmask);
sigprocmask(SIG_SETMASK, &nmask, &omask);
act.sa_handler = SIG_DFL;
sigemptyset(&act.sa_mask);
@@ -435,17 +428,19 @@
~0 & ~(1 << (signo-1)));
(void) fflush(stdout);
}
- (void) signal(signo, SIG_DFL);
- (void) KILL(getpid(), signo);
-
- signo = SIGCONT;
- Lst_ForEach(jobs, JobCondPassSig, (ClientData) &signo);
+ (void) kill(getpid(), signo);
+ if (signo != SIGTSTP) {
+ sigcont = SIGCONT;
+ Lst_ForEach(jobs, JobCondPassSig, (ClientData) &sigcont);
+ }
(void) sigprocmask(SIG_SETMASK, &omask, NULL);
sigprocmask(SIG_SETMASK, &omask, NULL);
- act.sa_handler = JobPassSig;
- sigaction(signo, &act, NULL);
+ if (signo != SIGCONT && signo != SIGTSTP) {
+ act.sa_handler = JobPassSig;
+ sigaction(sigcont, &act, NULL);
+ }
}
/*-
@@ -760,7 +755,7 @@
if ((WIFEXITED(*status) &&
(((WEXITSTATUS(*status) != 0) && !(job->flags & JOB_IGNERR)))) ||
- (WIFSIGNALED(*status) && (WTERMSIG(*status) != SIGCONT)))
+ WIFSIGNALED(*status))
{
/*
* If it exited non-zero and either we're doing things our
@@ -811,8 +806,7 @@
if (done ||
WIFSTOPPED(*status) ||
- (WIFSIGNALED(*status) && (WTERMSIG(*status) == SIGCONT)) ||
- DEBUG(JOB))
+ (WIFSIGNALED(*status) && (WTERMSIG(*status) == SIGCONT)))
{
FILE *out;
@@ -851,7 +845,7 @@
}
(void) fprintf(out, "*** Completed successfully\n");
}
- } else if (WIFSTOPPED(*status)) {
+ } else if (WIFSTOPPED(*status) && WSTOPSIG(*status) != SIGCONT) {
if (DEBUG(JOB)) {
(void) fprintf(stdout, "Process %d stopped.\n", job->pid);
(void) fflush(stdout);
@@ -861,8 +855,17 @@
lastNode = job->node;
}
if (!(job->flags & JOB_REMIGRATE)) {
- (void) fprintf(out, "*** Stopped -- signal %d\n",
- WSTOPSIG(*status));
+ switch (WSTOPSIG(*status)) {
+ case SIGTSTP:
+ (void) fprintf(out, "*** Suspended\n");
+ break;
+ case SIGSTOP:
+ (void) fprintf(out, "*** Stopped\n");
+ break;
+ default:
+ (void) fprintf(out, "*** Stopped -- signal %d\n",
+ WSTOPSIG(*status));
+ }
}
job->flags |= JOB_RESUME;
(void)Lst_AtEnd(stoppedJobs, (ClientData)job);
@@ -872,7 +875,7 @@
#endif
(void) fflush(out);
return;
- } else if (WTERMSIG(*status) == SIGCONT) {
+ } else if (WIFSTOPPED(*status) && WSTOPSIG(*status) == SIGCONT) {
/*
* If the beastie has continued, shift the Job from the stopped
* list to the running one (or re-stop it if concurrency is
@@ -947,7 +950,7 @@
break;
case JOB_ERROR:
done = TRUE;
- W_SETEXITSTATUS(status, 1);
+ *status = W_EXITCODE(1, 0);
break;
case JOB_FINISHED:
/*
@@ -1292,7 +1295,10 @@
_exit(1);
} else {
#ifdef REMOTE
- long omask = sigblock(sigmask(SIGCHLD));
+ sigset_t nmask, omask;
+ sigemptyset(&nmask);
+ sigaddset(&nmask, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &nmask, &omask);
#endif
job->pid = cpid;
@@ -1328,7 +1334,7 @@
}
}
#ifdef REMOTE
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif
}
@@ -1616,7 +1622,7 @@
* actually put the thing in the job table.
*/
job->flags |= JOB_CONTINUING;
- W_SETTERMSIG(&status, SIGCONT);
+ status = W_STOPCODE(SIGCONT);
JobFinish(job, &status);
job->flags &= ~(JOB_RESUME|JOB_CONTINUING);
@@ -1627,8 +1633,7 @@
} else {
Error("couldn't resume %s: %s",
job->node->name, strerror(errno));
- status = 0;
- W_SETEXITSTATUS(&status, 1);
+ status = W_EXITCODE(1, 0);
JobFinish(job, &status);
}
} else {
@@ -2250,7 +2255,8 @@
(block?0:WNOHANG)|WUNTRACED)) > 0)
{
if (DEBUG(JOB)) {
- (void) fprintf(stdout, "Process %d exited or stopped.\n", pid);
+ (void) fprintf(stdout, "Process %d exited or stopped %x.\n", pid,
+ status);
(void) fflush(stdout);
}
@@ -2258,7 +2264,7 @@
jnode = Lst_Find(jobs, (ClientData)&pid, JobCmpPid);
if (jnode == NILLNODE) {
- if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGCONT)) {
+ if (WIFSTOPPED(status) && (WSTOPSIG(status) == SIGCONT)) {
jnode = Lst_Find(stoppedJobs, (ClientData) &pid, JobCmpPid);
if (jnode == NILLNODE) {
Error("Resumed child (%d) not in table", pid);
Home |
Main Index |
Thread Index |
Old Index