diff options
| author | Tim Vanderhoek <hoek@FreeBSD.org> | 1999-08-22 05:29:09 +0000 |
|---|---|---|
| committer | Tim Vanderhoek <hoek@FreeBSD.org> | 1999-08-22 05:29:09 +0000 |
| commit | e1bff26ca7e8a053bb9e8de54d8b2d7f28c706ae (patch) | |
| tree | 0f5b0edd3e02d68424a1d68c04b331858a5e6ea5 /usr.bin/make | |
| parent | 2776a652bcf2b026e2301d00f67a413964b00a7b (diff) | |
Notes
Diffstat (limited to 'usr.bin/make')
| -rw-r--r-- | usr.bin/make/job.c | 26 | ||||
| -rw-r--r-- | usr.bin/make/job.h | 6 |
2 files changed, 17 insertions, 15 deletions
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index aa42d585369f..11f4fed50524 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -35,7 +35,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: job.c,v 1.10 1998/08/24 10:15:53 cracauer Exp $ + * $Id: job.c,v 1.11 1998/11/14 16:15:04 dg Exp $ */ #ifndef lint @@ -163,11 +163,10 @@ static int numCommands; /* The number of commands actually printed /* * tfile is the name of a file into which all shell commands are put. It is - * used over by removing it before the child shell is executed. The XXXXX in - * the string are replaced by the pid of the make process in a 5-character - * field with leading zeroes. + * used over by removing it before the child shell is executed. The XXXXXXXXXX + * in the string are replaced by mkstemp(3). */ -static char tfile[] = TMPPAT; +static char tfile[sizeof(TMPPAT)]; /* @@ -1667,7 +1666,6 @@ JobStart(gn, flags, previous) { register Job *job; /* new job descriptor */ char *argv[4]; /* Argument vector to shell */ - static int jobno = 0; /* job number of catching output in a file */ Boolean cmdsOK; /* true if the nodes commands were all right */ Boolean local; /* Set true if the job was run locally */ Boolean noExec; /* Set true if we decide not to run the job */ @@ -1874,8 +1872,7 @@ JobStart(gn, flags, previous) /* * If we're using pipes to catch output, create the pipe by which we'll * get the shell's output. If we're using files, print out that we're - * starting a job and then set up its temporary-file name. This is just - * tfile with two extra digits tacked on -- jobno. + * starting a job and then set up its temporary-file name. */ if (!compatMake || (job->flags & JOB_FIRST)) { if (usePipes) { @@ -1889,9 +1886,9 @@ JobStart(gn, flags, previous) } else { (void) fprintf(stdout, "Remaking `%s'\n", gn->name); (void) fflush(stdout); - sprintf(job->outFile, "%s%02d", tfile, jobno); - jobno = (jobno + 1) % 100; - job->outFd = open(job->outFile,O_WRONLY|O_CREAT|O_APPEND,0600); + (void) strcpy(job->outFile, TMPPAT); + if ((job->outFd = mkstemp(job->outFile)) == -1) + Punt("cannot create temp file: %s", strerror(errno)); (void) fcntl(job->outFd, F_SETFD, 1); } } @@ -2407,8 +2404,13 @@ Job_Init(maxproc, maxlocal) * be running at once. */ { GNode *begin; /* node for commands to do at the very start */ + int tfd; - (void) sprintf(tfile, "/tmp/make%05d", getpid()); + (void) strcpy(tfile, TMPPAT); + if ((tfd = mkstemp(tfile)) == -1) + Punt("cannot create temp file: %s", strerror(errno)); + else + (void) close(tfd); jobs = Lst_Init(FALSE); stoppedJobs = Lst_Init(FALSE); diff --git a/usr.bin/make/job.h b/usr.bin/make/job.h index 2d3e9619d41d..6dac5e497071 100644 --- a/usr.bin/make/job.h +++ b/usr.bin/make/job.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * from: @(#)job.h 8.1 (Berkeley) 6/6/93 - * $Id: job.h,v 1.7 1997/02/22 19:27:12 peter Exp $ + * $Id: job.h,v 1.8 1997/04/21 20:32:11 phk Exp $ */ /*- @@ -47,7 +47,7 @@ #ifndef _JOB_H_ #define _JOB_H_ -#define TMPPAT "/tmp/makeXXXXX" +#define TMPPAT "/tmp/makeXXXXXXXXXX" /* * The SEL_ constants determine the maximum amount of time spent in select @@ -128,7 +128,7 @@ typedef struct Job { } o_pipe; /* data used when catching the output via * a pipe */ struct { - char of_outFile[sizeof(TMPPAT)+2]; + char of_outFile[sizeof(TMPPAT)]; /* Name of file to which shell output * was rerouted */ int of_outFd; /* Stream open to the output |
