What are the different versions of exec used for C and C ++?

These are all versions of exec that can be used in C (and C ++)

execl execle execlp execv execve execvp 

What is the difference between the two? How do you know which one to use?

+76
c ++ c exec
Apr 24 2018-11-21T00:
source share
3 answers

Differences are combinations:

  • L vs V : do you want to pass parameters to exec'ed as

    • L : individual parameters in the call (list of variable arguments): execl() , execle() , execlp() and execlpe()
    • V : as an array of char * execv() , execve() , execvp() and execvpe()

    The array format is useful when the number of parameters that should be sent to the exec process are variables - as in a previously unknown one, so you cannot set a fixed number of parameters in a call function.

  • E. Versions with "e" at the end allow you to optionally pass an array of char *, which is a set of lines added to the environment of processed processes, before the program starts. Another way to pass parameters.

  • P : in versions with 'p', an environment path variable is used to search for an executable file called execute. For versions without "p", an absolute or relative path to the file is required, which must be added to the file name of the executable file if it is not in the current working directory.

+155
Apr 24 '11 at 9:45 a.m.
source share

Opengroup is one of the best generic links for core c / C ++ functions.

The documents for exec * are here: http://pubs.opengroup.org/onlinepubs/009695399/functions/environ.html

+5
Apr 24 2018-11-21T00:
source share

This is an extension of the Posix C runtime library. If the official Posix documentation is not enough, I can recommend the book - Samuel P. Harbison, Guy L. Steele, 2002 "CA Reference" Page No. 416 - consider this.

-3
Mar 26 '15 at 14:32
source share



All Articles