TEXT   87

execl.txt

Guest on 1st August 2021 05:58:40 PM

  1. NAME
  2.        execl,  execlp,  execle,  exect, execv, execvp - execute a
  3.        file
  4.  
  5.  
  6.  
  7. SYNOPSIS
  8.        #include <unistd.h>
  9.  
  10.        extern char **environ;
  11.  
  12.        int execl( const char *path, const char *arg, ...);
  13.        int execlp( const char *file, const char *arg, ...);
  14.        int execle( const char *path, const char *arg , ...,  char
  15.        * const envp[]);
  16.        int exect( const char *path, char *const argv[]);
  17.        int execv( const char *path, char *const argv[]);
  18.        int execvp( const char *file, char *const argv[]);
  19.  
  20.  
  21.  
  22. DESCRIPTION
  23.        The  exec family of functions replaces the current process
  24.        image with a new process image.  The  functions  described
  25.        in  this  manual  page  are  front-ends  for  the function
  26.        execve(2).  (See the manual page for execve  for  detailed
  27.        information about the replacement of the current process.)
  28.  
  29.        The initial argument for these functions is  the  pathname
  30.        of a file which is to be executed.
  31.  
  32.        The  const char *arg and subsequent ellipses in the execl,
  33.        execlp, and execle functions can be thought  of  as  arg0,
  34.        arg1,  ..., argn.  Together they describe a list of one or
  35.        more pointers to null-terminated  strings  that  represent
  36.        the  argument list available to the executed program.  The
  37.        first argument, by convention, should point  to  the  file
  38.        name associated with the file being executed.  The list of
  39.        arguments must be terminated by a NULL pointer.
  40.  
  41.        The exect, execv, and execvp functions provide an array of
  42.        pointers  to  null-terminated  strings  that represent the
  43.        argument list available to the  new  program.   The  first
  44.        argument,  by  convention,  should  point to the file name
  45.        associated with the file begin  executed.   The  array  of
  46.        pointers must be terminated by a NULL pointer.
  47.  
  48.        The  execle  and exect functions also specify the environ-
  49.        ment of the executed process by following the NULL pointer
  50.        that  terminates  the  list  of arguments in the parameter
  51.        list or the pointer to the argv array with  an  additional
  52.        parameter.   This  additional  parameter  is  an  array of
  53.        pointers to null-terminated strings and must be terminated
  54.        by  a NULL pointer.  The other functions take the environ-
  55.        ment for the new process image from the external  variable
  56.        environ in the current process.
  57.  
  58.        Some of these functions have special semantics.
  59.        The functions execlp and execvp will duplicate the actions
  60.        of the shell in searching for an executable  file  if  the
  61.        specified  file  name does not contain a slash (/) charac-
  62.        ter.  The search path is the path specified in  the  envi-
  63.        ronment  by  the  PATH  variable.   If this variable isn't
  64.        specified, the default path ``/bin:/usr/bin:'' is used (is
  65.        this  true  for  Linux?).  In addition, certain errors are
  66.        treated specially.
  67.  
  68.        If permission is denied for a file (the  attempted  execve
  69.        returned  EACCES), these functions will continue searching
  70.        the rest of the search path.  If no other file  is  found,
  71.        however,  they  will return with the global variable errno
  72.        set to EACCES.
  73.  
  74.        If the header of a file isn't  recognized  (the  attempted
  75.        execve returned ENOEXEC), these functions will execute the
  76.        shell with the path of the file  as  its  first  argument.
  77.        (If this attempt fails, no further searching is done.)
  78.  
  79.        If  the  file  is  currently  busy  (the  attempted execve
  80.        returned ETXTBUSY), these functions will sleep for several
  81.        seconds,  periodically  re-attempting to execute the file.
  82.        (Is this true for Linux?)
  83.  
  84.        The function exect executes a file with the program  trac-
  85.        ing facilities enabled (see ptrace(2).
  86.  
  87.  
  88.  
  89. RETURN VALUES
  90.        If  any  of the exec functions returns, an error will have
  91.        occurred.  The return value is -1, and the global variable
  92.        errno will be set to indicate the error.
  93.  
  94.  
  95.  
  96. FILES
  97.        /bin/sh
  98.  
  99.  
  100.  
  101. ERRORS
  102.        Execl,  execle,  execlp  and execvp may fail and set errno
  103.        for any of the errors specified for the library  functions
  104.        execve(2) and malloc(3).
  105.  
  106.        Exect  and  execv  may  fail  and set errno for any of the
  107.        errors specified for the library function execve(2).
  108.  
  109.  
  110.  
  111. SEE ALSO
  112.        sh(1), execve(2), fork(2), trace(2), environ(7), ptrace(2)
  113.  
  114.  
  115.  
  116. COMPATIBILITY
  117.        Historically,  the  default path for the execlp and execvp
  118.        functions was ``:/bin:/usr/bin''.   This  was  changed  to
  119.        place  the  current directory last to enhance system secu-
  120.        rity.
  121.  
  122.        The behavior of execlp and execvp when errors occur  while
  123.        attempting  to  execute the file is historic practice, but
  124.        has not traditionally been documented and is not specified
  125.        by the POSIX standard.
  126.  
  127.        Traditionally, the functions execlp and execvp ignored all
  128.        errors except for the ones described above and ENOMEM  and
  129.        E2BIG,  upon  which they returned.  They now return if any
  130.        error other than the ones described above occurs.
  131.  
  132.  
  133.  
  134. STANDARDS
  135.        Execl, execv, execle, execlp and execvp  conform  to  IEEE
  136.        Std1003.1-88 (``POSIX'').

Raw Paste


Login or Register to edit or fork this paste. It's free.