aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2016-01-01 17:44:57 +0100
committerMattias Andrée <maandree@member.fsf.org>2016-01-01 17:45:55 +0100
commitedd1b873f2a8b356ff2ff557e7b0e9497e404f38 (patch)
tree28114dee03e4dbef7de7c329de1b8a9d7cb7083a
parentbump year (diff)
downloadslibc-edd1b873f2a8b356ff2ff557e7b0e9497e404f38.tar.gz
slibc-edd1b873f2a8b356ff2ff557e7b0e9497e404f38.tar.bz2
slibc-edd1b873f2a8b356ff2ff557e7b0e9497e404f38.tar.xz
portability
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
-rw-r--r--TODO3
-rw-r--r--src/unistd/fexec.c12
2 files changed, 12 insertions, 3 deletions
diff --git a/TODO b/TODO
index ffe907c..e276d42 100644
--- a/TODO
+++ b/TODO
@@ -69,3 +69,6 @@ resulting string to 32765 bytes!
Can we implement any of these:
http://www.gnu.org/fun/jokes/errno.2
+Macros that are used but not defined:
+ _LINUX_
+
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;