Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Propagate errors from filemon.
details: https://anonhg.NetBSD.org/src/rev/18f1a0fb40bc
branches: trunk
changeset: 345210:18f1a0fb40bc
user: sjg <sjg%NetBSD.org@localhost>
date: Thu May 12 20:28:34 2016 +0000
description:
Propagate errors from filemon.
If we encounter errors producing a .meta file,
we should not consider the target completed successfully.
diffstat:
usr.bin/make/compat.c | 9 +++++----
usr.bin/make/job.c | 12 ++++++++----
usr.bin/make/meta.c | 38 +++++++++++++++++++++++++++-----------
usr.bin/make/meta.h | 6 +++---
4 files changed, 43 insertions(+), 22 deletions(-)
diffs (199 lines):
diff -r 106eb379e049 -r 18f1a0fb40bc usr.bin/make/compat.c
--- a/usr.bin/make/compat.c Thu May 12 18:57:38 2016 +0000
+++ b/usr.bin/make/compat.c Thu May 12 20:28:34 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.104 2016/02/18 18:29:14 christos Exp $ */
+/* $NetBSD: compat.c,v 1.105 2016/05/12 20:28:34 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.104 2016/02/18 18:29:14 christos Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.105 2016/05/12 20:28:34 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: compat.c,v 1.104 2016/02/18 18:29:14 christos Exp $");
+__RCSID("$NetBSD: compat.c,v 1.105 2016/05/12 20:28:34 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -583,7 +583,8 @@
}
#ifdef USE_META
if (useMeta && !NoExecute(gn)) {
- meta_job_finish(NULL);
+ if (meta_job_finish(NULL) != 0)
+ gn->made = ERROR;
}
#endif
diff -r 106eb379e049 -r 18f1a0fb40bc usr.bin/make/job.c
--- a/usr.bin/make/job.c Thu May 12 18:57:38 2016 +0000
+++ b/usr.bin/make/job.c Thu May 12 20:28:34 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.186 2016/02/18 18:29:14 christos Exp $ */
+/* $NetBSD: job.c,v 1.187 2016/05/12 20:28:34 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.186 2016/02/18 18:29:14 christos Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.187 2016/05/12 20:28:34 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: job.c,v 1.186 2016/02/18 18:29:14 christos Exp $");
+__RCSID("$NetBSD: job.c,v 1.187 2016/05/12 20:28:34 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -1043,7 +1043,11 @@
#ifdef USE_META
if (useMeta) {
- meta_job_finish(job);
+ int x;
+
+ if ((x = meta_job_finish(job)) != 0 && status == 0) {
+ status = x;
+ }
}
#endif
diff -r 106eb379e049 -r 18f1a0fb40bc usr.bin/make/meta.c
--- a/usr.bin/make/meta.c Thu May 12 18:57:38 2016 +0000
+++ b/usr.bin/make/meta.c Thu May 12 20:28:34 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.56 2016/05/10 23:45:45 sjg Exp $ */
+/* $NetBSD: meta.c,v 1.57 2016/05/12 20:28:34 sjg Exp $ */
/*
* Implement 'meta' mode.
@@ -157,28 +157,33 @@
* Read the build monitor output file and write records to the target's
* metadata file.
*/
-static void
+static int
filemon_read(FILE *mfp, int fd)
{
char buf[BUFSIZ];
int n;
+ int error;
/* Check if we're not writing to a meta data file.*/
if (mfp == NULL) {
if (fd >= 0)
close(fd); /* not interested */
- return;
+ return 0;
}
/* rewind */
(void)lseek(fd, (off_t)0, SEEK_SET);
+ error = 0;
fprintf(mfp, "\n-- filemon acquired metadata --\n");
while ((n = read(fd, buf, sizeof(buf))) > 0) {
- fwrite(buf, 1, n, mfp);
+ if ((int)fwrite(buf, 1, n, mfp) < n)
+ error = EIO;
}
fflush(mfp);
- close(fd);
+ if (close(fd) < 0)
+ error = errno;
+ return error;
}
#endif
@@ -753,27 +758,35 @@
}
}
-void
+int
meta_cmd_finish(void *pbmp)
{
+ int error = 0;
#ifdef USE_FILEMON
BuildMon *pbm = pbmp;
+ int x;
if (!pbm)
pbm = &Mybm;
if (pbm->filemon_fd >= 0) {
- close(pbm->filemon_fd);
- filemon_read(pbm->mfp, pbm->mon_fd);
+ if (close(pbm->filemon_fd) < 0)
+ error = errno;
+ x = filemon_read(pbm->mfp, pbm->mon_fd);
+ if (error == 0 && x != 0)
+ error = x;
pbm->filemon_fd = pbm->mon_fd = -1;
}
#endif
+ return error;
}
-void
+int
meta_job_finish(Job *job)
{
BuildMon *pbm;
+ int error = 0;
+ int x;
if (job != NULL) {
pbm = &job->bm;
@@ -781,11 +794,14 @@
pbm = &Mybm;
}
if (pbm->mfp != NULL) {
- meta_cmd_finish(pbm);
- fclose(pbm->mfp);
+ error = meta_cmd_finish(pbm);
+ x = fclose(pbm->mfp);
+ if (error == 0 && x != 0)
+ error = errno;
pbm->mfp = NULL;
pbm->meta_fname[0] = '\0';
}
+ return error;
}
void
diff -r 106eb379e049 -r 18f1a0fb40bc usr.bin/make/meta.h
--- a/usr.bin/make/meta.h Thu May 12 18:57:38 2016 +0000
+++ b/usr.bin/make/meta.h Thu May 12 20:28:34 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.h,v 1.4 2016/03/07 21:45:43 christos Exp $ */
+/* $NetBSD: meta.h,v 1.5 2016/05/12 20:28:34 sjg Exp $ */
/*
* Things needed for 'meta' mode.
@@ -48,8 +48,8 @@
void meta_job_child(struct Job *);
void meta_job_error(struct Job *, GNode *, int, int);
void meta_job_output(struct Job *, char *, const char *);
-void meta_cmd_finish(void *);
-void meta_job_finish(struct Job *);
+int meta_cmd_finish(void *);
+int meta_job_finish(struct Job *);
Boolean meta_oodate(GNode *, Boolean);
void meta_compat_start(void);
void meta_compat_child(void);
Home |
Main Index |
Thread Index |
Old Index