EXECL(3)

NAME
execl, execlp, execv, execvp - execute a file

SYNOPSIS
#include <unistd.h>

extern char **environ;

int execl(const char *path, const char *arg, ...);
int execle(const char *path, const char *rg, ...);
int execlp(const char *file, const char *arg, ...);
int execv(const char *path, char * const *argv);
int execvp(const char *file, char * const *argv);

DESCRIPTION
The exec family of functions replaces the current process image with a new process image. The functions described in this manual page are front-ends for the function execve(2). (See the manual page for execve for detailed information about the replacement of the current process.)

The initial argument for these functions is the pathname of a file which is to be executed.

The arg and subsequent ellipses in the execl, execle, and execlp functions can be thought of as arg0, arg1, ..., argn. Together they describe a list of one or more pointers to NULL-terminated strings that represent the argument list available to the executed program. The first argument, by convention, should point to the file name associated with the file being executed. The list of arguments must be terminated by a NULL pointer.

The execle function expects a final argument, envp, of type 'char * const *' to follow the trailing NULL pointer. This is an array of environment strings, similar to that used by execve(2). This array must be NULL-terminated.

The execv and execvp functions provide an array of pointers to NULL-terminated strings that represent the argument list available to the new program. The first argument, by convention, should point to the file name associated with the file begin executed. The array of pointers must be terminated by a NULL pointer.

Some of these functions have special semantics.

The functions execlp and execvp will duplicate the actions of the shell in searching for an executable file if the specified file name does not contain a slash (/) character or a colon (:). The search path is the path specified in the environment by PATH variable. If this variable isn't specified, the default path /bin /usr/bin (or /usr/bin /bin for gsh(1)) is used.

RETURN VALUES
If any of the exec functions returns, an error will have occurred. The return value is SYSERR (-1), and the global variable errno will be set to indicate the error.

ERRORS
These routines may fail and set errno for any of the errors specified for the library functions execve(2), _execve(2), and malloc(3).

GNO IMPLEMENTATION
When parsing the PATH environment variable, execvp and execlp assume that if there is no colon (:) within PATH then the pathname delimiter is a slash (/). This is to facilitate use of GS/OS pathname delimiters.

The current version of the gsh shell searches PATH from back to front. In most other shells, it is done front to back. In order to provide consistency with gsh, PATH is currently scanned back to front. With this backwards scanning, the default PATH used is /usr/bin /bin. If gsh gets fixed, the scan order will be quickly changed.

AUTHOR
Implemented from the BSD specification by Devin Reade.

SEE ALSO
execve(2), fork(2), exec(3C).

HISTORY
The GNO implementation of these routines first appeared in the lenviron library. They became part of the GNO distribution as of v2.0.6