execvp

OS/161 Reference Manual

Name

execvp - execute a program found on the search path

Library

Standard C Library (libc, -lc)

Synopsis

#include <unistd.h>

int
execvp(const char *program, char **args);

Description

execvp searches for program on the program search path and execs it with execv if found. If program is not found or a serious error occurs, it returns.

If program contains a slash, no search is done; the specified string is passed directly to execv.

The args argument should be prepared exactly as for execv.

The search path is a colon-delimited list of directories retrieved by calling getenv to retrieve the PATH environment variable. Unless you implement execve and environment variable passing, the value used is from a default environment compiled into libc. This path searches the /bin, /sbin, and /testbin directories.

Return Values

On success, execvp does not return; instead, the new program begins executing. On failure, execvp returns -1, and sets errno to a suitable error code for the error condition encountered.

Errors

execvp can fail for any of the reasons execv can. In addition, it produces ENOENT if the requested program is not found.