diff options
Diffstat (limited to 'usr.bin/make/job.c')
-rw-r--r-- | usr.bin/make/job.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index e37c62c..beb83dc 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -114,6 +114,8 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #include <fcntl.h> #include <inttypes.h> +#include <limits.h> +#include <paths.h> #include <string.h> #include <signal.h> #include <stdlib.h> @@ -137,7 +139,7 @@ __FBSDID("$FreeBSD$"); #include "util.h" #include "var.h" -#define TMPPAT "/tmp/makeXXXXXXXXXX" +#define TMPPAT "makeXXXXXXXXXX" #ifndef USE_KQUEUE /* @@ -236,7 +238,7 @@ typedef struct Job { */ struct { /* Name of file to which shell output was rerouted */ - char of_outFile[sizeof(TMPPAT)]; + char of_outFile[PATH_MAX]; /* * Stream open to the output file. Used to funnel all @@ -485,7 +487,7 @@ catch_child(int sig __unused) /** */ void -Proc_Init() +Proc_Init(void) { /* * Catch SIGCHLD so that we get kicked out of select() when we @@ -1008,17 +1010,6 @@ JobFinish(Job *job, int *status) if (!(job->flags & JOB_CONTINUING)) { DEBUGF(JOB, ("Warning: process %jd was not " "continuing.\n", (intmax_t) job->pid)); -#ifdef notdef - /* - * We don't really want to restart a - * job from scratch just because it - * continued, especially not without - * killing the continuing process! - * That's why this is ifdef'ed out. - * FD - 9/17/90 - */ - JobRestart(job); -#endif } job->flags &= ~JOB_CONTINUING; TAILQ_INSERT_TAIL(&jobs, job, link); @@ -1577,7 +1568,8 @@ JobStart(GNode *gn, int flags, Job *previous) Boolean noExec; /* Set true if we decide not to run the job */ int tfd; /* File descriptor for temp file */ LstNode *ln; - char tfile[sizeof(TMPPAT)]; + char tfile[PATH_MAX]; + const char *tdir; if (interrupted) { JobPassSig(interrupted); @@ -1618,6 +1610,9 @@ JobStart(GNode *gn, int flags, Job *previous) cmdsOK = TRUE; } + if ((tdir = getenv("TMPDIR")) == NULL) + tdir = _PATH_TMP; + /* * If the -n flag wasn't given, we open up OUR (not the child's) * temporary file to stuff commands in it. The thing is rd/wr so we @@ -1633,7 +1628,7 @@ JobStart(GNode *gn, int flags, Job *previous) DieHorribly(); } - strcpy(tfile, TMPPAT); + snprintf(tfile, sizeof(tfile), "%s/%s", tdir, TMPPAT); if ((tfd = mkstemp(tfile)) == -1) Punt("Cannot create temp file: %s", strerror(errno)); job->cmdFILE = fdopen(tfd, "w+"); @@ -1812,7 +1807,8 @@ JobStart(GNode *gn, int flags, Job *previous) } else { fprintf(stdout, "Remaking `%s'\n", gn->name); fflush(stdout); - strcpy(job->outFile, TMPPAT); + snprintf(job->outFile, sizeof(job->outFile), "%s/%s", + tdir, TMPPAT); if ((job->outFd = mkstemp(job->outFile)) == -1) Punt("cannot create temp file: %s", strerror(errno)); @@ -3380,6 +3376,8 @@ Compat_Run(Lst *targs) printf("`%s' not remade because of errors.\n", gn->name); makeErrors++; + } else if (gn->made == ERROR) { + makeErrors++; } } |