Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
execl(3)
Edit
PageHistory
Diff
Info
LikePages
EXEC !!!EXEC NAME SYNOPSIS DESCRIPTION RETURN VALUE FILES ERRORS SEE ALSO COMPATIBILITY CONFORMING TO ---- !!NAME execl, execlp, execle, execv, execvp - execute a file !!SYNOPSIS __#include __ __extern char **environ;__ __int execl( const char *__''path''__, const char *__''arg''__, ...); int execlp( const char *__''file''__, const char *__''arg''__, ...); int execle( const char *__''path''__, const char *__''arg'' __, ..., char * const__ ''envp''__[[]); 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 ''const char *arg'' and subsequent ellipses in the __execl__, __execlp__, and __execle__ 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 __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 being executed. The array of pointers ''must'' be terminated by a __NULL__ pointer. The __execle__ function also specifies the environment of the executed process by following the __NULL__ pointer that terminates the list of arguments in the parameter list or the pointer to the argv array with an additional parameter. This additional parameter is an array of pointers to null-terminated strings and ''must'' be terminated by a __NULL__ pointer. The other functions take the environment for the new process image from the external variable ''environ'' in the current process. 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. The search path is the path specified in the environment by the __PATH__ variable. If this variable isn't specified, the default path ``:/bin:/usr/bin'' is used. In addition, certain errors are treated specially. If permission is denied for a file (the attempted __execve__ returned __EACCES__), these functions will continue searching the rest of the search path. If no other file is found, however, they will return with the global variable ''errno'' set to __EACCES__. If the header of a file isn't recognized (the attempted __execve__ returned __ENOEXEC__), these functions will execute the shell with the path of the file as its first argument. (If this attempt fails, no further searching is done.) !!RETURN VALUE If any of the __exec__ functions returns, an error will have occurred. The return value is -1, and the global variable ''errno'' will be set to indicate the error. !!FILES ''/bin/sh'' !!ERRORS All of these functions may fail and set ''errno'' for any of the errors specified for the library function execve(2). !!SEE ALSO sh(1), execve(2), fork(2), environ(5), ptrace(2) !!COMPATIBILITY On some other systems the default path (used when the environment does not contain the variable __PATH__) has the current working directory listed after ''/bin'' and ''/usr/bin'', as an anti-Trojan-horse measure. Linux uses here the traditional '' The behavior of __execlp__ and __execvp__ when errors occur while attempting to execute the file is historic practice, but has not traditionally been documented and is not specified by the POSIX standard. BSD (and possibly other systems) do an automatic sleep and retry if ETXTBSY is encountered. Linux treats it as a hard error and returns immediately. Traditionally, the functions __execlp__ and __execvp__ ignored all errors except for the ones described above and __ENOMEM__ and __E2BIG__, upon which they returned. They now return if any error other than the ones described above occurs. !!CONFORMING TO __execl__, __execv__, __execle__, __execlp__ and __execvp__ conform to IEEE Std1003.1-88 (``POSIX.1''). ----
3 pages link to
execl(3)
:
EFAULT
Man3e
execve(2)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.