diff options
author | Mattias Andrée <maandree@member.fsf.org> | 2016-01-01 17:50:30 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@member.fsf.org> | 2016-01-01 17:50:30 +0100 |
commit | d45b0f627409c6646c65012bce6819dae7f9db1b (patch) | |
tree | f5c31154f98019f6a934ccdc4983a16be4a576f5 /src/unistd/execat.c | |
parent | portability (diff) | |
download | slibc-d45b0f627409c6646c65012bce6819dae7f9db1b.tar.gz slibc-d45b0f627409c6646c65012bce6819dae7f9db1b.tar.bz2 slibc-d45b0f627409c6646c65012bce6819dae7f9db1b.tar.xz |
m
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to '')
-rw-r--r-- | src/unistd/execat.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/unistd/execat.c b/src/unistd/execat.c index 87519e4..0005877 100644 --- a/src/unistd/execat.c +++ b/src/unistd/execat.c @@ -35,6 +35,17 @@ struct stat { int st_mode; }; /** + * The directory where all the process's file descriptors are available. + */ +#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 + + + +/** * The current environment variables. * * @since Always. @@ -415,11 +426,11 @@ int execveat(int dirfd, const char* path, char* const argv[], char* const envp[] return errno = ELOOP, -1; } - pathname = malloc(sizeof("/dev/fd//") + (3 * sizeof(int) + strlen(path)) * sizeof(char)); + pathname = malloc(sizeof(FD_PATH "//") + (3 * sizeof(int) + strlen(path)) * sizeof(char)); if (pathname == NULL) return -1; - sprintf(pathname, "/dev/fd/%i%s%s", dirfd, *path ? "/" : "", path); + sprintf(pathname, FD_PATH "/%i%s%s", dirfd, *path ? "/" : "", path); execve(pathname, argv, envp); saved_errno = errno; |