=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/compat.c,v retrieving revision 1.43 retrieving revision 1.44 diff -c -r1.43 -r1.44 *** src/usr.bin/make/compat.c 2001/11/22 23:56:43 1.43 --- src/usr.bin/make/compat.c 2001/11/23 23:42:45 1.44 *************** *** 1,5 **** /* $OpenPackages$ */ ! /* $OpenBSD: compat.c,v 1.43 2001/11/22 23:56:43 espie Exp $ */ /* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */ /* --- 1,5 ---- /* $OpenPackages$ */ ! /* $OpenBSD: compat.c,v 1.44 2001/11/23 23:42:45 deraadt Exp $ */ /* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */ /* *************** *** 77,96 **** static char meta[256]; static GNode *ENDNode; static void CompatInterrupt(int); static int CompatRunCommand(void *, void *); static void CompatMake(void *, void *); static int shellneed(char **); ! static volatile sig_atomic_t interrupted; ! ! static void CompatInterrupt(signo) ! int signo; { ! if (interrupted != SIGINT) ! interrupted = signo; } /*- --- 77,121 ---- static char meta[256]; + static GNode *curTarg = NULL; static GNode *ENDNode; static void CompatInterrupt(int); static int CompatRunCommand(void *, void *); static void CompatMake(void *, void *); static int shellneed(char **); ! /*- ! *----------------------------------------------------------------------- ! * CompatInterrupt -- ! * Interrupt the creation of the current target and remove it if ! * it ain't precious. ! * ! * Side Effects: ! * The target is removed and the process exits. If .INTERRUPT exists, ! * its commands are run first WITH INTERRUPTS IGNORED.. ! *----------------------------------------------------------------------- ! */ ! static void CompatInterrupt(signo) ! int signo; { ! GNode *gn; ! ! if (curTarg != NULL && !Targ_Precious(curTarg)) { ! char *file = Varq_Value(TARGET_INDEX, curTarg); ! ! if (!noExecute && eunlink(file) != -1) ! Error("*** %s removed\n", file); ! ! /* Run .INTERRUPT only if hit with interrupt signal. */ ! if (signo == SIGINT) { ! gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE); ! if (gn != NULL) ! Lst_Find(&gn->commands, CompatRunCommand, gn); ! } ! ! } ! _exit(signo); } /*- *************** *** 318,326 **** break; } - if (interrupted) - break; - if (stat != -1) { if (WIFSTOPPED(reason)) status = WSTOPSIG(reason); /* stopped */ --- 343,348 ---- *************** *** 348,378 **** status = 0; } } ! return !status; } else Fatal("error in wait: %d", stat); /*NOTREACHED*/ } ! /* This is reached only if interrupted */ ! if (!Targ_Precious(gn)) { ! char *file = Varq_Value(TARGET_INDEX, gn); ! ! if (!noExecute && eunlink(file) != -1) ! Error("*** %s removed\n", file); ! } ! if (interrupted == SIGINT) { ! GNode *i = Targ_FindNode(".INTERRUPT", TARG_NOCREATE); ! signal(SIGINT, SIG_IGN); ! signal(SIGTERM, SIG_IGN); ! signal(SIGHUP, SIG_IGN); ! signal(SIGQUIT, SIG_IGN); ! interrupted = 0; ! if (i != NULL) ! Lst_Find(&i->commands, CompatRunCommand, i); ! exit(SIGINT); ! } ! exit(interrupted); } /*- --- 370,382 ---- status = 0; } } ! break; } else Fatal("error in wait: %d", stat); /*NOTREACHED*/ } ! return !status; } /*- *************** *** 416,424 **** return; } ! if (Lst_Member(&gn->iParents, pgn) != NULL && ! (pgn->type & OP_IS_SUFFIX)) ! Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), pgn); /* All the children were made ok. Now cmtime contains the modification * time of the newest child, we need to find out if we exist and when --- 420,428 ---- return; } ! if (Lst_Member(&gn->iParents, pgn) != NULL) { ! Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), pgn); ! } /* All the children were made ok. Now cmtime contains the modification * time of the newest child, we need to find out if we exist and when *************** *** 454,462 **** if (Job_CheckCommands(gn, Fatal)) { /* Our commands are ok, but we still have to worry about the -t * flag... */ ! if (!touchFlag) Lst_Find(&gn->commands, CompatRunCommand, gn); ! else Job_Touch(gn, gn->type & OP_SILENT); } else gn->made = ERROR; --- 458,468 ---- if (Job_CheckCommands(gn, Fatal)) { /* Our commands are ok, but we still have to worry about the -t * flag... */ ! if (!touchFlag) { ! curTarg = gn; Lst_Find(&gn->commands, CompatRunCommand, gn); ! curTarg = NULL; ! } else Job_Touch(gn, gn->type & OP_SILENT); } else gn->made = ERROR; *************** *** 541,549 **** * to abort. */ pgn->make = false; else { ! if (Lst_Member(&gn->iParents, pgn) != NULL && ! (pgn->type & OP_IS_SUFFIX)) ! Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), pgn); switch (gn->made) { case BEINGMADE: Error("Graph cycles through %s\n", gn->name); --- 547,555 ---- * to abort. */ pgn->make = false; else { ! if (Lst_Member(&gn->iParents, pgn) != NULL) { ! Varq_Set(IMPSRC_INDEX, Varq_Value(TARGET_INDEX, gn), pgn); ! } switch (gn->made) { case BEINGMADE: Error("Graph cycles through %s\n", gn->name); *************** *** 574,583 **** GNode *gn = NULL;/* Current root target */ int errors; /* Number of targets not remade due to errors */ ! signal(SIGINT, CompatInterrupt); ! signal(SIGTERM, CompatInterrupt); ! signal(SIGHUP, CompatInterrupt); ! signal(SIGQUIT, CompatInterrupt); for (cp = "#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) meta[(unsigned char) *cp] = 1; --- 580,593 ---- GNode *gn = NULL;/* Current root target */ int errors; /* Number of targets not remade due to errors */ ! if (signal(SIGINT, SIG_IGN) != SIG_IGN) ! signal(SIGINT, CompatInterrupt); ! if (signal(SIGTERM, SIG_IGN) != SIG_IGN) ! signal(SIGTERM, CompatInterrupt); ! if (signal(SIGHUP, SIG_IGN) != SIG_IGN) ! signal(SIGHUP, CompatInterrupt); ! if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) ! signal(SIGQUIT, CompatInterrupt); for (cp = "#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) meta[(unsigned char) *cp] = 1;