Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between execl and execv?

Tags:

c

linux

exec

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?

like image 592
Ahmet Tanakol Avatar asked Feb 03 '12 04:02

Ahmet Tanakol


People also ask

How does execl differ from execv?

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.

What is execl () in Linux?

Description: The execl() function replaces the current process image with a new process image specified by path. The new image is constructed from a regular, executable file called the new process image file. No return is made because the calling process image is replaced by the new process image.

What does execv stand for?

execve() is a POSIX (and UNIX systems in general) function of the family of the exec*() functions that replace the current process image. The v comes from the fact that it takes an argument argv to the vector of arguments to the program (the same way the main function of a C program may take it).

What is the use of execl?

The execl function is most commonly used to overlay a process image that has been created by a call to the fork function. is the filename of the file that contains the executable image of the new process. is a variable length list of arguments that are passed to the new process image.


1 Answers

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

like image 89
mark4o Avatar answered Sep 20 '22 12:09

mark4o