aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-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;