execlpe()                Execute Program Using Arg List, Path, Environment
 
 #include   <process.h>
 
 int        execle(pathname, arg0,arg1...,argn,NULL,envp);
 int        execlpe(pathname,            arg0,arg1...,argn,NULL,envp);
 char       *pathname;                   Path name of file to be executed
 char       *arg0,*arg1...,argn;         List of pointers to arguments
 char       *envp;                       Array of pointers to environment
                                         settings
 
    execlpe() operates identically to execle(), with one exception: If
    'pathname' is not found as described in execl(), then execlpe() will
    use the DOS PATH to continue the search for pathname.  With that
    single exception, the two functions are identical; see execle() for a
    complete description.
 
  -------------------------------- Example ---------------------------------
 
    The following statements transfer execution to the child process
    "child.exe" and pass it the three arguments "child", "arg1", and
    "arg2".  "child.exe" will be found in the current directory or any
    PATH directory.  If "child.exe" is found, the PATH environment
    variable is set to "C:\\TEST" for the child process:
 
            #include <process.h>    /* for 'execlpe' */
            #include <stdio.h>      /* for 'printf' and 'NULL' */
            #include <stdlib.h>     /* for 'errno' */
            #include <errno.h>      /* for 'ENOENT' and 'ENOMEM' */
 
            char *env[] = {"PATH=C:\\TEST", NULL};
 
            main()
            {
                execlpe("child.exe", "child", "arg1", "arg2", NULL, env);
                /* only get here on an exec error */
                if (errno == ENOENT) {
                    printf("child.exe not found in current directory,\n");
                    printf("  or in any PATH directory\n");
                } else if (errno == ENOMEM)
                    printf("not enough memory to execute child.exe\n");
                else
                    printf("error #%d trying to exec child.exe\n", errno);
            }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster