Module Name: src
Committed By: rillig
Date: Sun Oct 18 07:46:04 UTC 2020
Modified Files:
src/usr.bin/make: compat.c job.c main.c meta.c nonints.h
Log Message:
make(1): replace execError with execDie
All calls to this function were followed by _exit(1).
To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/usr.bin/make/compat.c
cvs rdiff -u -r1.263 -r1.264 src/usr.bin/make/job.c
cvs rdiff -u -r1.371 -r1.372 src/usr.bin/make/main.c
cvs rdiff -u -r1.122 -r1.123 src/usr.bin/make/meta.c
cvs rdiff -u -r1.141 -r1.142 src/usr.bin/make/nonints.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.165 src/usr.bin/make/compat.c:1.166
--- src/usr.bin/make/compat.c:1.165 Mon Oct 5 19:27:47 2020
+++ src/usr.bin/make/compat.c Sun Oct 18 07:46:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.165 2020/10/05 19:27:47 rillig Exp $ */
+/* $NetBSD: compat.c,v 1.166 2020/10/18 07:46:04 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
#include "pathnames.h"
/* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.165 2020/10/05 19:27:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.166 2020/10/18 07:46:04 rillig Exp $");
static GNode *curTarg = NULL;
static pid_t compatChild;
@@ -348,8 +348,7 @@ Compat_RunCommand(const char *cmdp, stru
}
#endif
(void)execvp(av[0], (char *const *)UNCONST(av));
- execError("exec", av[0]);
- _exit(1);
+ execDie("exec", av[0]);
}
free(mav);
Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.263 src/usr.bin/make/job.c:1.264
--- src/usr.bin/make/job.c:1.263 Sat Oct 17 21:32:30 2020
+++ src/usr.bin/make/job.c Sun Oct 18 07:46:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.263 2020/10/17 21:32:30 rillig Exp $ */
+/* $NetBSD: job.c,v 1.264 2020/10/18 07:46:04 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.263 2020/10/17 21:32:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.264 2020/10/18 07:46:04 rillig Exp $");
# define STATIC static
@@ -1203,55 +1203,40 @@ JobExec(Job *job, char **argv)
* reset it to the beginning (again). Since the stream was marked
* close-on-exec, we must clear that bit in the new input.
*/
- if (dup2(fileno(job->cmdFILE), 0) == -1) {
- execError("dup2", "job->cmdFILE");
- _exit(1);
- }
- if (fcntl(0, F_SETFD, 0) == -1) {
- execError("fcntl clear close-on-exec", "stdin");
- _exit(1);
- }
- if (lseek(0, (off_t)0, SEEK_SET) == -1) {
- execError("lseek to 0", "stdin");
- _exit(1);
- }
+ if (dup2(fileno(job->cmdFILE), 0) == -1)
+ execDie("dup2", "job->cmdFILE");
+ if (fcntl(0, F_SETFD, 0) == -1)
+ execDie("fcntl clear close-on-exec", "stdin");
+ if (lseek(0, (off_t)0, SEEK_SET) == -1)
+ execDie("lseek to 0", "stdin");
if (job->node->type & (OP_MAKE | OP_SUBMAKE)) {
/*
* Pass job token pipe to submakes.
*/
- if (fcntl(tokenWaitJob.inPipe, F_SETFD, 0) == -1) {
- execError("clear close-on-exec", "tokenWaitJob.inPipe");
- _exit(1);
- }
- if (fcntl(tokenWaitJob.outPipe, F_SETFD, 0) == -1) {
- execError("clear close-on-exec", "tokenWaitJob.outPipe");
- _exit(1);
- }
+ if (fcntl(tokenWaitJob.inPipe, F_SETFD, 0) == -1)
+ execDie("clear close-on-exec", "tokenWaitJob.inPipe");
+ if (fcntl(tokenWaitJob.outPipe, F_SETFD, 0) == -1)
+ execDie("clear close-on-exec", "tokenWaitJob.outPipe");
}
/*
* Set up the child's output to be routed through the pipe
* we've created for it.
*/
- if (dup2(job->outPipe, 1) == -1) {
- execError("dup2", "job->outPipe");
- _exit(1);
- }
+ if (dup2(job->outPipe, 1) == -1)
+ execDie("dup2", "job->outPipe");
+
/*
* The output channels are marked close on exec. This bit was
* duplicated by the dup2(on some systems), so we have to clear
* it before routing the shell's error output to the same place as
* its standard output.
*/
- if (fcntl(1, F_SETFD, 0) == -1) {
- execError("clear close-on-exec", "stdout");
- _exit(1);
- }
- if (dup2(1, 2) == -1) {
- execError("dup2", "1, 2");
- _exit(1);
- }
+ if (fcntl(1, F_SETFD, 0) == -1)
+ execDie("clear close-on-exec", "stdout");
+ if (dup2(1, 2) == -1)
+ execDie("dup2", "1, 2");
/*
* We want to switch the child into a different process family so
@@ -1270,8 +1255,7 @@ JobExec(Job *job, char **argv)
Var_ExportVars();
(void)execv(shellPath, argv);
- execError("exec", shellPath);
- _exit(1);
+ execDie("exec", shellPath);
}
/* Parent, continuing after the child exec */
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.371 src/usr.bin/make/main.c:1.372
--- src/usr.bin/make/main.c:1.371 Mon Oct 5 22:45:47 2020
+++ src/usr.bin/make/main.c Sun Oct 18 07:46:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.371 2020/10/05 22:45:47 rillig Exp $ */
+/* $NetBSD: main.c,v 1.372 2020/10/18 07:46:04 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -122,7 +122,7 @@
#endif
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.371 2020/10/05 22:45:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.372 2020/10/18 07:46:04 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -1877,11 +1877,11 @@ eunlink(const char *file)
}
/*
- * execError --
+ * execDie --
* Print why exec failed, avoiding stdio.
*/
-void
-execError(const char *af, const char *av)
+void MAKE_ATTR_DEAD
+execDie(const char *af, const char *av)
{
#ifdef USE_IOVEC
int i = 0;
@@ -1907,6 +1907,7 @@ execError(const char *af, const char *av
while (writev(2, iov, 8) == -1 && errno == EAGAIN)
continue;
#endif
+ _exit(1);
}
/*
Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.122 src/usr.bin/make/meta.c:1.123
--- src/usr.bin/make/meta.c:1.122 Mon Sep 28 22:23:35 2020
+++ src/usr.bin/make/meta.c Sun Oct 18 07:46:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.122 2020/09/28 22:23:35 rillig Exp $ */
+/* $NetBSD: meta.c,v 1.123 2020/10/18 07:46:04 rillig Exp $ */
/*
* Implement 'meta' mode.
@@ -1647,11 +1647,8 @@ void
meta_compat_child(void)
{
meta_job_child(NULL);
- if (dup2(childPipe[1], 1) < 0 ||
- dup2(1, 2) < 0) {
- execError("dup2", "pipe");
- _exit(1);
- }
+ if (dup2(childPipe[1], 1) < 0 || dup2(1, 2) < 0)
+ execDie("dup2", "pipe");
}
void
Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.141 src/usr.bin/make/nonints.h:1.142
--- src/usr.bin/make/nonints.h:1.141 Sat Oct 17 21:32:30 2020
+++ src/usr.bin/make/nonints.h Sun Oct 18 07:46:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.141 2020/10/17 21:32:30 rillig Exp $ */
+/* $NetBSD: nonints.h,v 1.142 2020/10/18 07:46:04 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@ void Punt(const char *, ...) MAKE_ATTR_P
void DieHorribly(void) MAKE_ATTR_DEAD;
void Finish(int) MAKE_ATTR_DEAD;
int eunlink(const char *);
-void execError(const char *, const char *);
+void execDie(const char *, const char *);
char *getTmpdir(void);
Boolean s2Boolean(const char *, Boolean);
Boolean getBoolean(const char *, Boolean);