Question

I am working on a C program that needs to be able to execute certain commands using execvp, and I have implemented this with:

execvp(arguments[0], arguments);

where arguments[] is an array of stings. For the most part, my implementation works fine - e.g. if arguments is {"touch", "somefile.txt"} then the touch command is called as expected.

However, when I attempt to pass ls to execvp with arguments being something like {"/bin/ls", "-a", "."}, the ls function prints the directory listing as expected but also prints the error

ls: cannot access GLIBC_2.0: No such file or directory

I have no idea how to resolve this warning, and a google search has turned up nothing. Any ideas what is wrong?

Was it helpful?

Solution

The manual page of execvp says:

The execv() and execvp() functions provide an array of pointers to null-terminated strings that represent the argument list available to the new program. The first argument, by convention, should point to the filename associated with the file being executed. The array of pointers must be terminated by a NULL pointer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top