From 9ccd9576784d719eebc7cf8b5d9eda8544186b3a Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Mon, 1 Feb 2021 12:37:03 -0500 Subject: better diagnostics, find command in $PATH --- exec/exec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/exec/exec.c b/exec/exec.c index f3ee85e..c32c637 100644 --- a/exec/exec.c +++ b/exec/exec.c @@ -1,6 +1,7 @@ -#define _POSIX_SOURCE +#define _POSIX_C_SOURCE 200809L #include #include +#include #include #define NOT_RUN (126) @@ -13,8 +14,8 @@ int main(int argc, char *argv[]) return NOT_RUN; } - execv(argv[1], argv + 1); - perror(argv[0]); + execvp(argv[1], argv + 1); + fprintf(stderr, "%s: %s: %s\n", argv[0], argv[1], strerror(errno)); if (errno == ENOENT) { return NOT_FOUND; } -- cgit v1.2.1