Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make better error messages on exec* failures. From S...



details:   https://anonhg.NetBSD.org/src/rev/5e5b14a91750
branches:  trunk
changeset: 510450:5e5b14a91750
user:      christos <christos%NetBSD.org@localhost>
date:      Tue May 29 17:37:51 2001 +0000

description:
better error messages on exec* failures. From Simon Burge.

diffstat:

 usr.bin/make/compat.c  |  16 +++++++---------
 usr.bin/make/config.h  |   8 +++++++-
 usr.bin/make/job.c     |  12 ++++++------
 usr.bin/make/main.c    |  45 ++++++++++++++++++++++++++++++++++++++++-----
 usr.bin/make/nonints.h |   3 ++-
 5 files changed, 62 insertions(+), 22 deletions(-)

diffs (211 lines):

diff -r d9d217daf0d3 -r 5e5b14a91750 usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Tue May 29 13:03:01 2001 +0000
+++ b/usr.bin/make/compat.c     Tue May 29 17:37:51 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.32 2001/04/06 11:13:46 wiz Exp $  */
+/*     $NetBSD: compat.c,v 1.33 2001/05/29 17:37:51 christos Exp $     */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -39,14 +39,14 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: compat.c,v 1.32 2001/04/06 11:13:46 wiz Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.33 2001/05/29 17:37:51 christos 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.32 2001/04/06 11:13:46 wiz Exp $");
+__RCSID("$NetBSD: compat.c,v 1.33 2001/05/29 17:37:51 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -282,13 +282,11 @@
     }
     if (cpid == 0) {
        Check_Cwd(av);
-       if (local) {
-           execvp(av[0], av);
-           (void) write (2, av[0], strlen (av[0]));
-           (void) write (2, ": not found\n", sizeof(": not found"));
-       } else {
+       if (local)
+           (void)execvp(av[0], av);
+       else
            (void)execv(av[0], av);
-       }
+       execError(av[0]);
        _exit(1);
     }
     if (bp) {
diff -r d9d217daf0d3 -r 5e5b14a91750 usr.bin/make/config.h
--- a/usr.bin/make/config.h     Tue May 29 13:03:01 2001 +0000
+++ b/usr.bin/make/config.h     Tue May 29 17:37:51 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: config.h,v 1.10 1999/05/03 12:01:14 christos Exp $     */
+/*     $NetBSD: config.h,v 1.11 2001/05/29 17:37:52 christos Exp $     */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -118,6 +118,12 @@
  */
 #define USE_PGRP
 
+/*
+ * USE_IOVEC
+ *     We have writev(2)
+ */
+#define USE_IOVEC
+
 #if !defined(__svr4__) && !defined(__SVR4) && !defined(__ELF__)
 # ifndef RANLIBMAG
 #  define RANLIBMAG "__.SYMDEF"
diff -r d9d217daf0d3 -r 5e5b14a91750 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Tue May 29 13:03:01 2001 +0000
+++ b/usr.bin/make/job.c        Tue May 29 17:37:51 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.47 2001/05/01 03:27:50 sommerfeld Exp $      */
+/*     $NetBSD: job.c,v 1.48 2001/05/29 17:37:52 christos Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -39,14 +39,14 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: job.c,v 1.47 2001/05/01 03:27:50 sommerfeld Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.48 2001/05/29 17:37:52 christos 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.47 2001/05/01 03:27:50 sommerfeld Exp $");
+__RCSID("$NetBSD: job.c,v 1.48 2001/05/29 17:37:52 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1377,10 +1377,10 @@
            Rmt_Exec(shellPath, argv, FALSE);
        } else
 #endif /* REMOTE */
+       {
           (void) execv(shellPath, argv);
-
-       (void) write(2, "Could not execute shell\n",
-                    sizeof("Could not execute shell"));
+          execError(shellPath);
+       }
        _exit(1);
     } else {
 #ifdef REMOTE
diff -r d9d217daf0d3 -r 5e5b14a91750 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Tue May 29 13:03:01 2001 +0000
+++ b/usr.bin/make/main.c       Tue May 29 17:37:51 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.65 2001/01/16 02:37:03 cgd Exp $    */
+/*     $NetBSD: main.c,v 1.66 2001/05/29 17:37:52 christos Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -39,7 +39,7 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: main.c,v 1.65 2001/01/16 02:37:03 cgd Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.66 2001/05/29 17:37:52 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -51,7 +51,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.65 2001/01/16 02:37:03 cgd Exp $");
+__RCSID("$NetBSD: main.c,v 1.66 2001/05/29 17:37:52 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -110,6 +110,10 @@
 #include "pathnames.h"
 #include "trace.h"
 
+#ifdef USE_IOVEC
+#include <sys/uio.h>
+#endif
+
 #ifndef        DEFMAXLOCAL
 #define        DEFMAXLOCAL DEFMAXJOBS
 #endif /* DEFMAXLOCAL */
@@ -1567,6 +1571,37 @@
 }
 
 /*
+ * execError --
+ *     Print why exec failed, avoiding stdio.
+ */
+void
+execError(av)
+       const char *av;
+{
+#ifdef USE_IOVEC
+       int i = 0;
+       struct iovec iov[6];
+#define IOADD(s) \
+       (void)(iov[i].iov_base = (s), \
+           iov[i].iov_len = strlen(iov[i].iov_base), \
+           i++)
+#else
+#define        IOADD (void)write(2, s, strlen(s))
+#endif
+
+       IOADD(progname);
+       IOADD(": Exec of `");
+       IOADD((char *)av);
+       IOADD("' failed (");
+       IOADD(strerror(errno));
+       IOADD(")\n");
+
+#ifdef USE_IOVEC
+       (void)writev(2, iov, 6);
+#endif
+}
+
+/*
  * usage --
  *     exit with usage message
  */
@@ -1574,9 +1609,9 @@
 usage()
 {
        (void)fprintf(stderr,
-"usage: make [-Beiknqrst] [-D variable] [-d flags] [-f makefile ]\n\
+"Usage: %s [-Beiknqrst] [-D variable] [-d flags] [-f makefile ]\n\
             [-I directory] [-j max_jobs] [-m directory] [-V variable]\n\
-            [variable=value] [target ...]\n");
+            [variable=value] [target ...]\n", progname);
        exit(2);
 }
 
diff -r d9d217daf0d3 -r 5e5b14a91750 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Tue May 29 13:03:01 2001 +0000
+++ b/usr.bin/make/nonints.h    Tue May 29 17:37:51 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nonints.h,v 1.20 2000/12/03 02:18:14 christos Exp $    */
+/*     $NetBSD: nonints.h,v 1.21 2001/05/29 17:37:52 christos Exp $    */
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -83,6 +83,7 @@
 void *erealloc __P((void *, size_t));
 void enomem __P((void));
 int eunlink __P((const char *));
+void execError __P((const char *));
 
 /* parse.c */
 void Parse_Error __P((int, char *, ...))



Home | Main Index | Thread Index | Old Index