Proposal: execvP
Tim Kientzle
kientzle at acm.org
Mon Jun 23 15:22:54 PDT 2003
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
More information about the freebsd-arch
mailing list