diff options
author | Mattias Andrée <maandree@member.fsf.org> | 2016-01-01 17:44:57 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@member.fsf.org> | 2016-01-01 17:45:55 +0100 |
commit | edd1b873f2a8b356ff2ff557e7b0e9497e404f38 (patch) | |
tree | 28114dee03e4dbef7de7c329de1b8a9d7cb7083a /src | |
parent | bump year (diff) | |
download | slibc-edd1b873f2a8b356ff2ff557e7b0e9497e404f38.tar.gz slibc-edd1b873f2a8b356ff2ff557e7b0e9497e404f38.tar.bz2 slibc-edd1b873f2a8b356ff2ff557e7b0e9497e404f38.tar.xz |
portability
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/unistd/fexec.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/unistd/fexec.c b/src/unistd/fexec.c index 2f2b229..36352ce 100644 --- a/src/unistd/fexec.c +++ b/src/unistd/fexec.c @@ -186,15 +186,21 @@ int fexecv(int fd, char* const argv[]) */ int fexecve(int fd, char* const argv[], char* const envp[]) { - char pathname[sizeof("/proc/self/fd//") + 3 * sizeof(int)]; +#if defined(_LINUX_) +# define FD_PATH "/proc/self/fd" /* /dev/fd works but it is a symbolic link. */ +#else +# define FD_PATH "/dev/fd" +#endif + + char pathname[sizeof(FD_PATH "//") + 3 * sizeof(int)]; int saved_errno; - sprintf(pathname, "/proc/self/fd/%i/", fd); + sprintf(pathname, FD_PATH "/%i/", fd); execve(pathname, argv, envp); saved_errno = errno; - if (access("/proc/", X_OK)) + if (access(FD_PATH "/", X_OK)) saved_errno = ENOSYS; errno = saved_errno == ENOENT ? EBADF : saved_errno; |