0

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?

4

2 回答 2

1

Because "command not found" does not correspond to a standard error code (see e.g. http://linux.die.net/man/3/errno).

于 2011-04-23T23:51:33.140 回答
1

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.

于 2011-04-23T23:52:54.677 回答