Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>execl</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
execl
execv
execle
execlp
execvp
execve

Usage

   #include <process.h>
   #include <errno.h>  /* for error checking only */
   int execl(const char *path,const char *arglist,...)
   int execv(const char *path,const char *argv)
   int execlp(const char *file,const char *arglist,...)
   int execvp(const char *file,const char *argv)

Description

   The exec functions load and execute new child processes. When the call is
   successful, the child process is placed in the memory previously occupied
   by the calling process. Sufficient memory must be available for loading
   and executing the child process. All of the functions in this family use
   the same exec function the letter(s) at the end determine the specific
   variation:

       Letter              Variation
       ---------------     -----------------------------------------
         p                 Uses the PATH environment variable to

                           find the file to be executed.

         l                 Command line arguments are passed
        (lower case L)     individually to the exec function.

         v                 Command line arguments are passed to
                           the exec function as an array of pointers.

Example 

   #include <errno.h>
   #include <process.h>
   #include <stdio.h>
   #include <stdlib.h>

   int main(int argc,char *argv[])
   {
       char *args[4];
       int result;
       args[0] = "arg0";

       args[1] = "arg1";
       args[2] = "arg2";
       args[3] = NULL;
       switch (argv[1][0])
       {
           case '1':
               execl("myprog","arg0","arg1","arg2",NULL);
               break;
           case '2':
               execlp("myprog","arg0","arg1","arg2",NULL);
               break;
           case '3':
               execv("myprog",args);
               break;
           case '4':
               execvp("myprog",args);
               break;
           default:
           printf("Enter a number between 1 and 4 on"
                                           "the command line\n");

       }
       printf("Process myprog not exececuted.\n");
       return EXIT_FAILURE;
   }

Return Value

   The exec functions do not normally return to the calling process. If an
   exec function returns, an error has occurred and the return value is -1.
   In this case errno is set to one of the following values:

   E2BIG            The argument list exceeds the system limit.

   EACCES           The specified file has a locking or sharing violation

   ENOENT           The file or path name not found.

   ENOMEM           Not enough memory is available to execute the child
                    process or the available memory has been corrupted.





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