insert unknown command to execvp()
hi if i开发者_运维问答'm passing an unknown command to execvp i'm getting this error in the errno : "no such file or directory" when i should get this error: "command not found"
how can i get the second error?
Because "command not found" does not correspond to a standard error code (see e.g. http://linux.die.net/man/3/errno).
There is no "command not found" error that can be returned from execvp. The closest is ENOENT, which means that the file specified (or its interpreter, or a required dynamic library) was not found.
If you want, your program could print out "command not found" rather than the text returned by strerror.
精彩评论