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

This commit is contained in:
christos 2001-05-29 17:37:51 +00:00
parent 3529d6d10f
commit d0c243e9e5
5 changed files with 62 additions and 22 deletions

View File

@ -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 @@ CompatRunCommand (cmdp, gnp)
}
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) {

View File

@ -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"

View File

@ -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 @@ JobExec(job, argv)
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

View File

@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\n\
#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 @@ __RCSID("$NetBSD: main.c,v 1.65 2001/01/16 02:37:03 cgd Exp $");
#include "pathnames.h"
#include "trace.h"
#ifdef USE_IOVEC
#include <sys/uio.h>
#endif
#ifndef DEFMAXLOCAL
#define DEFMAXLOCAL DEFMAXJOBS
#endif /* DEFMAXLOCAL */
@ -1566,6 +1570,37 @@ eunlink(file)
return unlink(file);
}
/*
* 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 @@ static void
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);
}

View File

@ -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 *emalloc __P((size_t));
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 *, ...))