When executing the above code, it just does an ls on the current directory. Array element  is completely ignored.Code:char* ls_args; ls_args = "../.."; ls_args = 0; execve("/bin/ls", ls_args, 0);
This works; it actually does an ls on the directory two levels up. However, notice the contents of array element .char* ls_args;
ls_args = "the first array value has absolutely no effect whatsoever";
ls_args = "../..";
ls_args = 0;
execve("/bin/ls", ls_args, 0);
What is going on here?
I tried looking it up on the man pages, but I don't understand what it says. Here is an excerpt:
... Huh? What file?http:// www.opengroup.org/onlinepubs/000095399/functions/exec.html
execl(<shell path>, arg0, file, arg1, ..., (char *)0);
The argument arg0 should point to a filename that is associated with the process being started by one of the exec functions.
Also, the examples on the same page always have the command listed twice, such as:
Can anyone explain the purpose of the first array element in laymen's terms?ret = execle ("/bin/ls", "ls", "-l", (char *)0, env);