home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / EXECV.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  5.5 KB  |  117 lines

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