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()
.
Related videos on Youtube
Author by
Ahmet Tanakol
Updated on June 04, 2022Comments
-
Ahmet Tanakol almost 2 years
I use
execv
instead ofexecl
. To useexecv
, I create an array and put arguments that I use withexecl
in there. Then I put this array intoexecv
I know I have to use an array of arguments for
execv
but why? What is the difference betweenexecl
andexecv
?-
jww about 5 yearsPossible duplicate of What are the different versions of exec used for in C and C++?
-
-
Ahmet Tanakol about 12 yearsWhy do we need the change the format of the arguments? I mean if they are doing same thing
-
mark4o about 12 yearsThe
execve()
system call (andexecv()
) 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 forexecl()
. -
mig001 about 2 yearsHere is an example: stackoverflow.com/a/32142863