summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/fexecve.c
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-12-27 19:51:23 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-12-27 19:51:23 +0000
commit9a47d57c4784163dcf838c7461c53de29ca7a61f (patch)
tree80c130f3da27db25996b0a5f93270df554dcd8b4 /sysdeps/unix/sysv/linux/fexecve.c
parente0b77a51a258fc7554aeb194ac6b219ee3078f0d (diff)
parent82dd75a7f436a19047325d62182590c9f9e23a78 (diff)
Merge branch 't/tls' into refs/top-bases/tschwinge/Roger_Whittaker
Diffstat (limited to 'sysdeps/unix/sysv/linux/fexecve.c')
-rw-r--r--sysdeps/unix/sysv/linux/fexecve.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/sysdeps/unix/sysv/linux/fexecve.c b/sysdeps/unix/sysv/linux/fexecve.c
index 1800d6402b..3560b711ca 100644
--- a/sysdeps/unix/sysv/linux/fexecve.c
+++ b/sysdeps/unix/sysv/linux/fexecve.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -19,8 +19,13 @@
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
+#include <fcntl.h>
#include <sys/stat.h>
+#include <sysdep.h>
+#include <sys/syscall.h>
+#include <kernel-features.h>
+
/* Execute the file FD refers to, overlaying the running program image.
ARGV and ENVP are passed to the new program, as for `execve'. */
@@ -33,6 +38,16 @@ fexecve (int fd, char *const argv[], char *const envp[])
return -1;
}
+#ifdef __NR_execveat
+ /* Avoid implicit array coercion in syscall macros. */
+ INLINE_SYSCALL (execveat, 5, fd, "", &argv[0], &envp[0], AT_EMPTY_PATH);
+# ifndef __ASSUME_EXECVEAT
+ if (errno != ENOSYS)
+ return -1;
+# endif
+#endif
+
+#ifndef __ASSUME_EXECVEAT
/* We use the /proc filesystem to get the information. If it is not
mounted we fail. */
char buf[sizeof "/proc/self/fd/" + sizeof (int) * 3];
@@ -50,6 +65,7 @@ fexecve (int fd, char *const argv[], char *const envp[])
save = ENOSYS;
__set_errno (save);
+#endif
return -1;
}