diff options
Diffstat (limited to '')
-rw-r--r-- | src/unistd/exec.c | 19 | ||||
-rw-r--r-- | src/unistd/execat.c | 25 | ||||
-rw-r--r-- | src/unistd/fexec.c | 6 |
3 files changed, 30 insertions, 20 deletions
diff --git a/src/unistd/exec.c b/src/unistd/exec.c index 70b54f6..0b76259 100644 --- a/src/unistd/exec.c +++ b/src/unistd/exec.c @@ -21,6 +21,9 @@ #include <alloca.h> #include <string.h> #include <stdlib.h> +/* TODO temporary contants from other headers { */ +#define _CS_PATH 1 +/* } */ @@ -114,8 +117,8 @@ int execlp(const char* file, ... /*, NULL */) { int saved_errno; va_list argv; - va_start(argv, path); - vexec(path, argv, 0, 1); + va_start(argv, file); + vexec(file, argv, 0, 1); saved_errno = errno; va_end(argv); return errno = saved_errno, -1; @@ -180,8 +183,8 @@ int execlpe(const char* file, ... /*, NULL, char* const envp[] */) { int saved_errno; va_list argv; - va_start(argv, path); - vexec(path, argv, 1, 1); + va_start(argv, file); + vexec(file, argv, 1, 1); saved_errno = errno; va_end(argv); return errno = saved_errno, -1; @@ -236,7 +239,7 @@ int execv(const char* path, char* const argv[]) */ int execvp(const char* file, char* const argv[]) { - return execvpe(path, argv, environ); + return execvpe(file, argv, environ); } @@ -265,7 +268,7 @@ int execvp(const char* file, char* const argv[]) int execve(const char* path, char* const argv[], char* const envp[]) { return errno = ENOTSUP, -1; - (void) path, (void) argv, (void) enpv; + (void) path, (void) argv, (void) envp; /* TODO implement execve */ } @@ -314,7 +317,7 @@ int execvpe(const char* file, char* const argv[], char* const envp[]) if (!*file) return errno = ENOENT, -1; - path = getenv(PATH); + path = getenv("PATH"); if (path == NULL) { if ((len = confstr(_CS_PATH, NULL, 0))) @@ -352,7 +355,7 @@ int execvpe(const char* file, char* const argv[], char* const envp[]) free(path); free(pathname); - return errno = (eaccess ? EACCES : ENOENT), -1; + return errno = (eacces ? EACCES : ENOENT), -1; fail: saved_errno = errno; diff --git a/src/unistd/execat.c b/src/unistd/execat.c index a90fffb..bcff176 100644 --- a/src/unistd/execat.c +++ b/src/unistd/execat.c @@ -22,8 +22,15 @@ #include <string.h> #include <stdlib.h> #include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> +/* TODO #include <sys/types.h> */ +/* TODO #include <sys/stat.h> */ +/* TODO temporary contants/structs from other headers { */ +#define AT_FDCWD 1 +#define AT_EMPTY_PATH 1 +#define AT_SYMLINK_NOFOLLOW 1 +#define _CS_PATH 1 +struct stat { int st_mode; }; +/* } */ @@ -150,8 +157,8 @@ int execlpat(int dirfd, const char* file, ... /*, NULL, int flags */) { int saved_errno; va_list argv; - va_start(argv, path); - vexecat(dirfd, path, argv, 0, 1); + va_start(argv, file); + vexecat(dirfd, file, argv, 0, 1); saved_errno = errno; va_end(argv); return errno = saved_errno, -1; @@ -244,8 +251,8 @@ int execlpeat(int dirfd, const char* file, ... /*, NULL, char* const[] envp, int { int saved_errno; va_list argv; - va_start(argv, path); - vexecat(dirfd, path, argv, 1, 1); + va_start(argv, file); + vexecat(dirfd, file, argv, 1, 1); saved_errno = errno; va_end(argv); return errno = saved_errno, -1; @@ -330,7 +337,7 @@ int execvat(int dirfd, const char* path, char* const argv[], int flags) */ int execvpat(int dirfd, const char* file, char* const argv[], int flags) { - return execvpe(dirfd, path, argv, environ, flags); + return execvpeat(dirfd, file, argv, environ, flags); } @@ -452,7 +459,7 @@ int execvpeat(int dirfd, const char* file, char* const argv[], char* const envp[ if (strchr(file, '/') || !*file) return execveat(dirfd, file, argv, envp, flags); - path = getenv(PATH); + path = getenv("PATH"); if (path == NULL) { execveat(dirfd, file, argv, envp, flags); @@ -494,7 +501,7 @@ int execvpeat(int dirfd, const char* file, char* const argv[], char* const envp[ free(path); free(pathname); - return errno = (eaccess ? EACCES : ENOENT), -1; + return errno = (eacces ? EACCES : ENOENT), -1; fail: saved_errno = errno; diff --git a/src/unistd/fexec.c b/src/unistd/fexec.c index bf2c392..7a8d4f5 100644 --- a/src/unistd/fexec.c +++ b/src/unistd/fexec.c @@ -40,7 +40,7 @@ extern char** environ; * * @throws Any error specified for execve(2). */ -static void vexec(int fd, va_list argv, int fetch_envp) +static void vfexec(int fd, va_list argv, int fetch_envp) { char* const* envp = environ; size_t n = 0, i; @@ -84,7 +84,7 @@ int fexecl(int fd, ... /*, NULL */) { int saved_errno; va_list argv; - va_start(argv, path); + va_start(argv, fd); vfexec(fd, argv, 0); saved_errno = errno; va_end(argv); @@ -116,7 +116,7 @@ int fexecle(int fd, ... /*, NULL, char* const envp[] */) { int saved_errno; va_list argv; - va_start(argv, path); + va_start(argv, fd); vfexec(fd, argv, 1); saved_errno = errno; va_end(argv); |