1 #define _GNU_SOURCE
2 #include <unistd.h>
3 #include <errno.h>
4 #include <fcntl.h>
5 #include "syscall.h"
6 #include <unsupported_api.h>
7
fexecve(int fd,char * const argv[],char * const envp[])8 int fexecve(int fd, char *const argv[], char *const envp[])
9 {
10 unsupported_api(__FUNCTION__);
11 int r = __syscall(SYS_execveat, fd, "", argv, envp, AT_EMPTY_PATH);
12 if (r != -ENOSYS) return __syscall_ret(r);
13 char buf[15 + 3*sizeof(int)];
14 __procfdname(buf, fd);
15 execve(buf, argv, envp);
16 if (errno == ENOENT) errno = EBADF;
17 return -1;
18 }
19