Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): split Job.jobPipe into 2 separate fields
details: https://anonhg.NetBSD.org/src/rev/6e3c90cc3bff
branches: trunk
changeset: 944407:6e3c90cc3bff
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Sep 28 00:06:36 2020 +0000
description:
make(1): split Job.jobPipe into 2 separate fields
Just because these file descriptors have to be in an array when they are
created is not reason enough to keep this array and a few access macros
in the Job struct. It's better to have separate fields, as they can be
documented independently.
diffstat:
usr.bin/make/job.c | 16 ++++++++++------
usr.bin/make/job.h | 8 +++-----
2 files changed, 13 insertions(+), 11 deletions(-)
diffs (75 lines):
diff -r 5af65caa2a9d -r 6e3c90cc3bff usr.bin/make/job.c
--- a/usr.bin/make/job.c Sun Sep 27 23:59:37 2020 +0000
+++ b/usr.bin/make/job.c Mon Sep 28 00:06:36 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.248 2020/09/27 23:56:25 rillig Exp $ */
+/* $NetBSD: job.c,v 1.249 2020/09/28 00:06:36 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.248 2020/09/27 23:56:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.249 2020/09/28 00:06:36 rillig Exp $");
# define STATIC static
@@ -401,19 +401,23 @@
JobCreatePipe(Job *job, int minfd)
{
int i, fd, flags;
+ int pipe_fds[2];
- if (pipe(job->jobPipe) == -1)
+ if (pipe(pipe_fds) == -1)
Punt("Cannot create pipe: %s", strerror(errno));
for (i = 0; i < 2; i++) {
/* Avoid using low numbered fds */
- fd = fcntl(job->jobPipe[i], F_DUPFD, minfd);
+ fd = fcntl(pipe_fds[i], F_DUPFD, minfd);
if (fd != -1) {
- close(job->jobPipe[i]);
- job->jobPipe[i] = fd;
+ close(pipe_fds[i]);
+ pipe_fds[i] = fd;
}
}
+ job->inPipe = pipe_fds[0];
+ job->outPipe = pipe_fds[1];
+
/* Set close-on-exec flag for both */
if (fcntl(job->inPipe, F_SETFD, FD_CLOEXEC) == -1)
Punt("Cannot set close-on-exec: %s", strerror(errno));
diff -r 5af65caa2a9d -r 6e3c90cc3bff usr.bin/make/job.h
--- a/usr.bin/make/job.h Sun Sep 27 23:59:37 2020 +0000
+++ b/usr.bin/make/job.h Mon Sep 28 00:06:36 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.h,v 1.52 2020/09/27 23:12:12 rillig Exp $ */
+/* $NetBSD: job.h,v 1.53 2020/09/28 00:06:36 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -163,7 +163,8 @@
* commands */
#define JOB_TRACED 0x400 /* we've sent 'set -x' */
- int jobPipe[2]; /* Pipe for reading output from job */
+ int inPipe; /* Pipe for reading output from job */
+ int outPipe; /* Pipe for writing control commands */
struct pollfd *inPollfd; /* pollfd associated with inPipe */
#define JOB_BUFSIZE 1024
@@ -176,9 +177,6 @@
#endif
} Job;
-#define inPipe jobPipe[0]
-#define outPipe jobPipe[1]
-
/*-
* Shell Specifications:
* Each shell type has associated with it the following information:
Home |
Main Index |
Thread Index |
Old Index