OS/161 Reference Manual


execvp - execute a program found on the search path


Standard C Library (libc, -lc)


#include <unistd.h>

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


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.


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