Exemple #1
0
/*-
 *-----------------------------------------------------------------------
 * CompatInterrupt --
 *	Interrupt the creation of the current target and remove it if
 *	it ain't precious.
 *
 * Results:
 *	None.
 *
 * Side Effects:
 *	The target is removed and the process exits. If .INTERRUPT exists,
 *	its commands are run first WITH INTERRUPTS IGNORED..
 *
 *-----------------------------------------------------------------------
 */
static void
CompatInterrupt(int signo)
{
    GNode   *gn;

    if ((curTarg != NULL) && !Targ_Precious (curTarg)) {
	char	  *p1;
	char 	  *file = Var_Value(TARGET, curTarg, &p1);

	if (!noExecute && eunlink(file) != -1) {
	    Error("*** %s removed", file);
	}
	if (p1)
	    free(p1);

	/*
	 * Run .INTERRUPT only if hit with interrupt signal
	 */
	if (signo == SIGINT) {
	    gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
	    if (gn != NULL) {
		Compat_Make(gn, gn);
	    }
	}

    }
    _exit(signo);
}
Exemple #2
0
int main(int argc, char *argv[]) {
	struct stat a, b;
	char path[] = "test_O_TRUC";
	int fd = eopen(path, O_RDWR | O_CREAT | O_TRUNC);
	efstat(fd, &a);
	eclose(fd);
	fd = eopen(path, O_RDWR | O_CREAT | O_TRUNC);
	efstat(fd, &b);
	aver(a.st_ino == b.st_ino);
	eclose(fd);
	eunlink(path);
	return 0;
}
Exemple #3
0
static void
handle_compat_interrupts(GNode *gn)
{
    if (!Targ_Precious(gn)) {
        char *file = Var(TARGET_INDEX, gn);

        if (!noExecute && eunlink(file) != -1)
            Error("*** %s removed\n", file);
    }
    if (got_SIGINT) {
        signal(SIGINT, SIG_IGN);
        signal(SIGTERM, SIG_IGN);
        signal(SIGHUP, SIG_IGN);
        signal(SIGQUIT, SIG_IGN);
        got_signal = 0;
        got_SIGINT = 0;
        run_gnode(interrupt_node);
        exit(255);
    }
    exit(255);
}
Exemple #4
0
/*-
 *-----------------------------------------------------------------------
 * JobInterrupt --
 *	Handle the receipt of an interrupt.
 *
 * Side Effects:
 *	All children are killed. Another job will be started if the
 *	.INTERRUPT target was given.
 *-----------------------------------------------------------------------
 */
static void
JobInterrupt(bool runINTERRUPT,	/* true if commands for the .INTERRUPT
				 * target should be executed */
    int signo)			/* signal received */
{
	LstNode ln;		/* element in job table */
	Job *job; 		/* job descriptor in that element */

	aborting = ABORT_INTERRUPT;

	for (ln = Lst_First(&runningJobs); ln != NULL; ln = Lst_Adv(ln)) {
		job = (Job *)Lst_Datum(ln);

		if (!Targ_Precious(job->node)) {
			const char *file = job->node->path == NULL ?
			    job->node->name : job->node->path;
			if (!noExecute && eunlink(file) != -1) {
				Error("*** %s removed", file);
			}
		}
		if (job->pid) {
			debug_printf("JobInterrupt passing signal to "
			    "child %ld.\n", (long)job->pid);
			killpg(job->pid, signo);
		}
	}

	if (runINTERRUPT && !touchFlag) {
		if ((interrupt_node->type & OP_DUMMY) == 0) {
			ignoreErrors = false;

			JobStart(interrupt_node, 0);
			loop_handle_running_jobs();
		}
	}
	exit(signo);
}