l
and v
in exec calls denote whether the arguments are provided via list or array(vector)
. I read it somewhere that p
denotes the user's path and e
denote the environment but did not understand what that means?
2 Answers
Check this Wikipedia link on Exec function and this link on Starting a process with the exec() calls
e – An array of pointers to environment variables is explicitly passed to the new process image.
The "e" suffix versions pass an environment to the program. An environment is just that—a kind of "context" for the program to operate in. For example, you may have a spelling checker that has a dictionary of words. Instead of specifying the dictionary's location every time on the command line, you could provide it in the environment:
l – Command-line arguments are passed individually (a list) to the function.
For example, if I want to invoke the ls command with the arguments -t, -r, and -l (meaning "sort the output by time, in reverse order, and show me the long version of the output"), I could specify it as either.
p – Uses the PATH environment variable to find the file named in the path argument to be executed.
The "p" suffix versions will search the directories in your PATH environment variable to find the executable. You've probably noticed that all the examples have a hard-coded location for the executable: /bin/ls and /usr/bin/spellcheck. What about other executables? Unless you want to first find out the exact path for that particular program, it would be best to have the user tell your program all the places to search for executables. The standard PATH environment variable does just that.
v – Command-line arguments are passed to the function as an array (vector) of pointers.
The argument list is specified via a pointer to an argument vector.
As mentioned in the other answer, this link on Unix System Calls is also equally awesome for further reading.
-
@sekhar suman : Where are these environment variables stored? In the kernel? Commented Jul 24, 2015 at 8:42
-
@saurav1405-Check this question, you need to look for environ file in your user specific process for getting to know the environment variables applicable to that process. Like, /proc/<pid>/environ and read it's contents. Commented Jul 24, 2015 at 9:20
According to http://www.di.uevora.pt/~lmr/syscalls.html, the suffixes indicate the type of arguments:
l argn is specified as a list of arguments.
v argv is specified as a vector (array of character pointers).
e environment is specified as an array of character pointers.
p user's PATH is searched for command, and command can be a shell program