What is the difference between execl and execv?

19,031

There is no difference other than the format of the arguments. They will both end up calling the same underlying system call execve().

Share:
19,031

Related videos on Youtube

Ahmet Tanakol
Author by

Ahmet Tanakol

Updated on June 04, 2022

Comments

  • Ahmet Tanakol
    Ahmet Tanakol almost 2 years

    I use execv instead of execl. To use execv, I create an array and put arguments that I use with execl in there. Then I put this array into execv

    I know I have to use an array of arguments for execv but why? What is the difference between execl and execv?

  • Ahmet Tanakol
    Ahmet Tanakol about 12 years
    Why do we need the change the format of the arguments? I mean if they are doing same thing
  • mark4o
    mark4o about 12 years
    The execve() system call (and execv()) take the arguments in an array. execl() is just provided as a convenience, in case you have a fixed number of arguments, to allow you to avoid the trouble of setting up an array. execl() will store the function arguments in a temporary array itself and then make the system call. If you set up the argument array yourself then you have no need for execl().
  • mig001
    mig001 about 2 years
    Here is an example: stackoverflow.com/a/32142863