make(1): exit 2 on technical errors
This allows the -q option to distinguish errors from out-of-date targets. Granted, it's an edge case but it should be solved consistently anyway. The majority of cases in which make exits with exit status 1, even in -q mode, is when there are parse errors. These have been kept as-is for now as they affect many of the unit tests. The technical errors, on the other hand, occur so rarely that it's hard to write reliable tests for them that fail consistently on all platforms supported by make.
This commit is contained in:
parent
7c7dae763b
commit
bb4b461edd
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dir.c,v 1.252 2020/12/13 20:14:48 rillig Exp $ */
|
||||
/* $NetBSD: dir.c,v 1.253 2020/12/27 11:47:04 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
|
@ -136,7 +136,7 @@
|
|||
#include "job.h"
|
||||
|
||||
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
|
||||
MAKE_RCSID("$NetBSD: dir.c,v 1.252 2020/12/13 20:14:48 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: dir.c,v 1.253 2020/12/27 11:47:04 rillig Exp $");
|
||||
|
||||
/* A search path is a list of CachedDir structures. A CachedDir has in it the
|
||||
* name of the directory and the names of all the files in the directory.
|
||||
|
@ -506,7 +506,7 @@ Dir_InitDot(void)
|
|||
dir = Dir_AddDir(NULL, ".");
|
||||
if (dir == NULL) {
|
||||
Error("Cannot open `.' (%s)", strerror(errno));
|
||||
exit(1);
|
||||
exit(2); /* Not 1 so -q can distinguish error */
|
||||
}
|
||||
|
||||
CachedDir_Assign(&dot, dir);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: main.c,v 1.504 2020/12/27 05:16:26 rillig Exp $ */
|
||||
/* $NetBSD: main.c,v 1.505 2020/12/27 11:47:04 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -109,7 +109,7 @@
|
|||
#include "trace.h"
|
||||
|
||||
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
|
||||
MAKE_RCSID("$NetBSD: main.c,v 1.504 2020/12/27 05:16:26 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: main.c,v 1.505 2020/12/27 11:47:04 rillig Exp $");
|
||||
#if defined(MAKE_NATIVE) && !defined(lint)
|
||||
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
|
||||
"The Regents of the University of California. "
|
||||
|
@ -373,7 +373,7 @@ MainParseArgChdir(const char *argvalue)
|
|||
if (chdir(argvalue) == -1) {
|
||||
(void)fprintf(stderr, "%s: chdir %s: %s\n",
|
||||
progname, argvalue, strerror(errno));
|
||||
exit(1);
|
||||
exit(2); /* Not 1 so -q can distinguish error */
|
||||
}
|
||||
if (getcwd(curdir, MAXPATHLEN) == NULL) {
|
||||
(void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno));
|
||||
|
@ -426,7 +426,7 @@ MainParseArgJobs(const char *argvalue)
|
|||
(void)fprintf(stderr,
|
||||
"%s: illegal argument to -j -- must be positive integer!\n",
|
||||
progname);
|
||||
exit(1); /* XXX: why not 2? */
|
||||
exit(2); /* Not 1 so -q can distinguish error */
|
||||
}
|
||||
Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
|
||||
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
|
||||
|
@ -1241,7 +1241,7 @@ InitMaxJobs(void)
|
|||
"%s: illegal value for .MAKE.JOBS "
|
||||
"-- must be positive integer!\n",
|
||||
progname);
|
||||
exit(1);
|
||||
exit(2); /* Not 1 so -q can distinguish error */
|
||||
}
|
||||
|
||||
if (n != opts.maxJobs) {
|
||||
|
@ -1931,7 +1931,7 @@ DieHorribly(void)
|
|||
if (DEBUG(GRAPH2))
|
||||
Targ_PrintGraph(2);
|
||||
Trace_Log(MAKEERROR, NULL);
|
||||
exit(2); /* Not 1, so -q can distinguish error */
|
||||
exit(2); /* Not 1 so -q can distinguish error */
|
||||
}
|
||||
|
||||
/* Called when aborting due to errors in child shell to signal abnormal exit.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: parse.c,v 1.517 2020/12/27 05:06:17 rillig Exp $ */
|
||||
/* $NetBSD: parse.c,v 1.518 2020/12/27 11:47:04 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -117,7 +117,7 @@
|
|||
#include "pathnames.h"
|
||||
|
||||
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
|
||||
MAKE_RCSID("$NetBSD: parse.c,v 1.517 2020/12/27 05:06:17 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: parse.c,v 1.518 2020/12/27 11:47:04 rillig Exp $");
|
||||
|
||||
/* types and constants */
|
||||
|
||||
|
@ -527,7 +527,7 @@ loadfile(const char *path, int fd)
|
|||
if (lf->len > SIZE_MAX / 2) {
|
||||
errno = EFBIG;
|
||||
Error("%s: file too large", path);
|
||||
exit(1);
|
||||
exit(2); /* Not 1 so -q can distinguish error */
|
||||
}
|
||||
lf->len *= 2;
|
||||
lf->buf = bmake_realloc(lf->buf, lf->len);
|
||||
|
@ -536,7 +536,7 @@ loadfile(const char *path, int fd)
|
|||
result = read(fd, lf->buf + bufpos, lf->len - bufpos);
|
||||
if (result < 0) {
|
||||
Error("%s: read error: %s", path, strerror(errno));
|
||||
exit(1);
|
||||
exit(2); /* Not 1 so -q can distinguish error */
|
||||
}
|
||||
if (result == 0)
|
||||
break;
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue