Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Jun 2003 15:25:22 -0700
From:      Tim Kientzle <kientzle@acm.org>
To:        arch@freebsd.org, ru@freebsd.org
Subject:   Proposal: execvP
Message-ID:  <3EF77E52.6070007@acm.org>

next in thread | raw e-mail | index | archive | help
I've encountered a couple of places now where I could really use
an exec* function that is identical to execvp(3), except that
it accepts a path specification instead of automatically using
the PATH environment variable.

For lack of a better name, I propose adding
the following to lib/libc/gen/exec.c:

/* Exec 'file', searching the specified path. */
int
execvP(const char *file, const char *path, char *const argv[]);

The implementation itself is trivial;
a three-line edit converts the existing execvp()
into execvP(), and then execvp() gets
a new implementation as follows:

int
execvp(const char *file, char *const argv[])
{
     const char *path;

     path = getenv("PATH");
     if(!path) path = _PATH_DEFPATH;
     return execvP(file,path,argv);
}

In essence, execvP() is merely publishing an already-existing capability
within the library by breaking execvp() into two very natural pieces.
Without this, I basically will have to copy a slightly modified version
of execvp() into several utilities, which seems a rather pointless
exercise.

Thoughts?

Tim Kientzle



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3EF77E52.6070007>