home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 2.ddi / CLIBSRC3.ZIP / EXECV.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  5.3 KB  |  114 lines

  1. /*------------------------------------------------------------------------
  2.  * filename - execv.c
  3.  *
  4.  * function(s)
  5.  *        execv - load and execute a program
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*
  9.  *      C/C++ Run Time Library - Version 5.0
  10.  *
  11.  *      Copyright (c) 1987, 1992 by Borland International
  12.  *      All Rights Reserved.
  13.  *
  14.  */
  15.  
  16.  
  17. #include <process.h>
  18. #include <_process.h>
  19. #include <stddef.h>
  20.  
  21. /*---------------------------------------------------------------------------*
  22.  
  23. Name            exec... - functions that load and run other programs
  24.  
  25. Usage           int  execv(char *pathname, char *argv[]);
  26.  
  27. Prototype in    process.h
  28.  
  29. Description     The functions in the exec...  family load and run (execute)
  30.                 other programs,  known as child processes.  When an exec...
  31.                 call is  successful, the child process  overlays the parent
  32.                 process.  There  must  be  sufficient  memory available for
  33.                 loading and executing the child process.
  34.  
  35.                 pathname is the file name  of the called child process. The
  36.                 exec...  functions search  for pathname  using the standard
  37.                 MS-DOS search algorithm:
  38.  
  39.                         . If no explicit extension is given, the function
  40.                           will search for the file as given. If that one is
  41.                           not found, the function will add .COM and search
  42.                           again. If that's not found, it will add .EXE and
  43.                           search one last time.
  44.  
  45.                         . If an explicit extension or period is given, the
  46.                           function will search for the file as given.
  47.  
  48.                 The suffixes l,  v, p and e added to  exec... "family name"
  49.                 specify that  the named function will  operate with certain
  50.                 capabilities.
  51.  
  52.                         p specifies  that the function will  search for the
  53.                           child in  those directories specified by  the DOS
  54.                           PATH environment variable. If pathname does not
  55.                           contain an explicit directory the function will
  56.                           search first the current directory then in the
  57.                           directory specified by the path. Without the p
  58.                           suffix, the  function only  searches the current
  59.                           working directory.
  60.  
  61.                         l specifies that the argument pointers (arg0, arg1,
  62.                           ...,  argn)  are  passed  as  separate arguments.
  63.                           Typically, the l suffix is  used when you know in
  64.                           advance the  number of arguments to  be passed. A
  65.                           mandatory  NULL following  argn marks  the end of
  66.                           the list.
  67.  
  68.                         v specifies  that  the argument  pointers (argv[0],
  69.                           argv[1], ..., argv[n]) are  passed as an array of
  70.                           pointers.  Typically,  the  v  suffix  is  used a
  71.                           variable number of arguments is to be passed.
  72.  
  73.                         e specifies that the  argument envp maybe passed to
  74.                           the  child  process,  allowing  you  to alter the
  75.                           environment for the child  process. Without the e
  76.                           suffix, child process inherits the environment of
  77.                           the parent process.  This environment argument is
  78.                           an  array of  char *.  Each element  points to  a
  79.                           null-terminated character string of the form:
  80.  
  81.                                 envar=value
  82.  
  83.                           where  envar  is  the   name  of  an  environment
  84.                           variable, and value is  the string value to which
  85.                           envar is set. The last element of envp[] is NULL.
  86.                           When  envp[0]  is  NULL,  the  child inherits the
  87.                           parent's environment settings.
  88.  
  89.                 The  exec... functions  must at  least one  argument to the
  90.                 child process. This  argument is, by convention, a  copy of
  91.                 pathname.  Under MS-DOS  3.x, pathname is available for the
  92.                 child process; under earlier versions, the child cannot use
  93.                 the passed value of arg0 (or argv[0]).
  94.  
  95.                 When  an exec...  function call   is made,  any open  files
  96.                 remain open in the child process.
  97.  
  98. Return value    If  successful, the  exec...  functions  do not  return. On
  99.                 error, the exec... functions return -1, and errno is set to
  100.                 one of the following:
  101.                         E2BIG   Argument list too long
  102.                         EACCES  Permission denied
  103.                         EMFILE  Too many open files
  104.                         ENOENT  Path or file name not found
  105.                         ENOEXEC Exec format error
  106.                         ENOMEM  Not enough core
  107.  
  108. *---------------------------------------------------------------------------*/
  109. int execv(char *pathP, char *argv[])
  110. {
  111.         return(_LoadProg(_exec, pathP, argv, NULL, 0));
  112. }
  113.  
  114.