Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>execvp() execute program using argument array, path</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 execvp()                Execute Program Using Argument Array, PATH

 #include   <process.h>

 int        execvp(pathname,argv);
 char       *pathname;                   Path name of file to be executed
 char       *argv[];                     Array of pointer to arguments

    execvp() operates identically to execv(), with one exception: If
    'pathname' is not found as described in execv(), then execvp() will
    use the DOS PATH to continue the search for pathname.  With that
    single exception, the two functions are identical; see execv() for a
    complete description.

 Portability:   Xenix, OS/2, or MS-DOS 3.0 or higher.

   ------------------------------ Example ------------------------------

    The following statements transfer execution to the child process
    "child.exe" and pass it the three arguments "child", "arg1", and
    "arg2".  "child.exe" can be found if it exists in the current
    directory or any directory in the DOS PATH.

           #include <process.h>    /* for 'execvp' */
           #include <stdio.h>      /* for 'printf' and 'NULL' */
           #include <stdlib.h>     /* for 'errno' */
           #include <errno.h>      /* for 'ENOENT' and 'ENOMEM' */

           char *args[] = {"child", "arg1", "arg2", NULL};

           main()
           {
               execvp("child.exe", args);
               /* 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);
           }


See Also: execv() execve() spawnl()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson